Is it possible to format the input from the serial monitor?

But as you can see from the OP, the serial monitor does format the code if the string is included (as a string) in the sketch. It is only the string that is inputted that isn't formatted. What I want to achieve is to send MicroPython code to a device running MicroPython. I can do this, for instance, with the response from the OpenAI API or by including the string in the sketch, so why can't I do it with a string inputted via the monitor?