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.
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. There is a Korean folktale of The Cunning Servant.