One of Jack Vance’s Dying Earth books features this as a whole chapter, the first of the Cugel books I believe. I don’t know of an earlier appearance of the concept.