Coding =/= labor. Also, the whole point of ai is to get it to a point where it can tell itself what to do, no?
Not really, it will follow after what was imposed to it via programming like any other autonomous machine. The idea behind AI is that it fine-tunes itself ("learns") as it operates. It tries to make the best choice for a given circumstance given a certain goal.
So like, as an example: you put an AI into a dummy and wants it to run as fast as possible from point A to point B. You'll code literally mathematical functions, and give it some parameters that will be slightly altered over time. It will try a certain technique (given by the values of the parameters plugged into the function), then another one, then compare which one performed better and pick the better one (farther away, or fastest in this case). Then it will try another slightly different technique, then it will compare and pick the better one, and so on.
Or as another example, an AI algorithm that converts writing of the scanned pages of a book (an image) into text characters. In this case the way to see how well it's performing is by comparing with the correct answer (this was vastly done in the past in the form of people filling out captchas! usually there were two prompts, half of them were for verifying if you were a bot, and half of them were to train AIs - nowadays it's often seen with images rather than text). It keeps "practicing" until it perfects said skill.
When people say it will substitute, like, physical labor, that's certainly a possibility, but it will take ages for it to be done because it will require extremely extensive training. And it's not like it will exclude all forms of work, as people will still need to make sure these are working properly, take care of maintenance, program, etc.