Where the escape runs
It runs on every input that reaches the model, including inputs from tools and files. There is no input class that is trusted by default.
Why the escape is a function, not a prompt
A prompt asks. A function does. The escape must happen whether or not the model agrees with it.