Wiktionary
n. A fictional character who fits into the archetype of being lower-class, more clever than the other characters, and helping the protagonists.
Wikipedia
The tricky slave is a stock character. He is a clever, lower-class person who brings about the happy ending of a comedy for the lovers. He is more clever than the upper-class people about him, both the lovers and the characters who block their love, and typically also looking out for his own interests; in the New Comedy, the tricky slave or dolosus servus aimed to get his freedom by assisting his young master in love.
Besides the actual slaves of classical theater, he also appears as the scheming valet in Renaissance comedy, called the gracioso in Spanish. The zanni of Commedia dell'arte are often tricky slaves, as are Puss-in-Boots in Perrault's fairy tale, Jeeves in P. G. Wodehouse's work and Figaro.
In fairy tales, the same function is often fulfilled by fairy godmothers, talking animals, and like creatures.
Northrop Frye identified him as a central portion of the Myth of Spring comedy and a type of eiron character.
A female version of the tricky slave would be Morgiana, a clever slave girl from " Ali Baba and the Forty Thieves" in the One Thousand and One Nights (Arabian Nights). She is initially in Cassim's household but on his death she joins his brother Ali Baba and through her quick wittedness she saves Ali's life many times and eventually kills his worst enemy, the leader of the Forty Thieves. As reward, Ali frees her and Morgiana marries Cassim's son.
In contrast to these positive depictions, the tricky slave is portrayed as the antagonist in another Arabian Nights tale, " The Three Apples", an early example of a murder mystery. After the murderer reveals himself near the middle of a story, he narrates the events leading up to the murder in a flashback. Within this flashback, a slave convinces him of his wife's infidelity, thus leading to her murder.