Preventing code from appearing in TTS and assistant Text

Complete noob apologies.

I have HA running in a docker, and separate dockers for Whisper and Piper. along with Ollama running on that machine.

essentially its all working fine, however when I use my voice assistant and give a command such as “what is the status of x sensor” anyhting that involves reaching out to HA elements. the Text returned contains elements like “,”parameters”:{}}”

If I ask a generic question like who wrote Moby dick all that is fine.

I have been going in circles and I believe I understand I need a python script or automation script of some kind to parse the text before it reaches piper.

any help much appreciated