gentle-quill-48181
12/11/2025, 11:09 PMHello, I'm facing an unusual problem with my agent. Sometimes it sends and say values like <|audio_text|>, as in the example below:
Copy code{ "id": "item_Clh60LcmD6UIgb8CEL6U4", "type": "message", "role": "assistant", "content": [ "<|audio_text|>" ], "interrupted": false, "extra": {}, "metrics": { "started_speaking_at": 1765483113.0202394, "stopped_speaking_at": 1765483114.1185155 } }
This is my AgentSession:
session = AgentSession(
userdata=userdata,
llm=openai.realtime.RealtimeModel.with_azure(modalities=["text"]),
tts=elevenlabs.TTS( voice_settings=VoiceSettings(stability=0.5, similarity_boost=0.75,style=0.0,speed=1.0,use_speaker_boost=True)))My problem is that this <|audio_text|> is being sent to my user (the person interacting with the agent). I don't just want to remove it from the history; I want it to never be spoken again.
Any idea what it could be?
tall-airline-16756
12/11/2025, 11:09 PMtall-airline-16756
12/11/2025, 11:10 PMllm = openai.realtime.RealtimeModel.with_azure(modalities=["text"])
1. Intercept and clean model output before it reaches TTS by adding a transcription node that strips the token:
async def transcription_node(self, text: AsyncIterable[str], model_settings: ModelSettings) -> AsyncIterable[str]:
async for chunk in text:
cleaned = chunk.replace("<|audio_text|>", "").strip()
if cleaned:
yield cleaned
• This guarantees the token never gets forwarded to ElevenLabs or the user.
Optional checks
• Confirm no other part of your pipeline (frontend, session config, or other plugins) is enabling audio responses or injecting control tokens.
• Keep your external TTS (ElevenLabs) as the only speech path so the model’s audio tokens are irrelevant.
If you’d like, share a short sample of the raw model stream or your pipeline code around where you send text to TTS and I’ll point to the exact spot to add the transcription_node.
Sources: OpenAI Realtime API plugin guide | LiveKit docs | Pipeline nodes and hooks | LiveKit docs | Text and transcriptions | LiveKit docsgentle-quill-48181
12/11/2025, 11:10 PMtall-airline-16756
12/11/2025, 11:11 PMllm = openai.realtime.RealtimeModel.with_azure(modalities=["text"])
2) Intercept and filter output before TTS by implementing a transcription node on your AgentSession (or override the method your agent uses to stream LLM output). Example async transcription node:
async def transcription_node(self, text: AsyncIterable[str], model_settings) -> AsyncIterable[str]:
async for chunk in text:
# remove placeholder tokens and trim whitespace
cleaned = chunk.replace("<|audio_text|>", "").strip()
if cleaned:
yield cleaned
3) If your pipeline uses a different hook (e.g., llm_node in Node agent code), apply the same filtering there before enqueuing chunks to TTS.
What to check
• Place this node in the path that sends text to your ElevenLabs TTS so the placeholder is removed before any speech synthesis.
• Keep modalities=["text"] so audio-control tokens are less likely to appear.
If you want, paste the small section of your agent pipeline where you pass LLM output to TTS and I’ll point exactly where to insert the node.
Sources: Agents v0.x migration guide - Node.js | LiveKit Docs | Pipeline nodes and hooks | LiveKit docs | Modifying LLM output before TTS | LiveKit docs