This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.
I’m facing an unusual problem with my agent. Sometimes it sends and speaks values like <|audio_text|>, as in the example below:
{
"id": "item_Clh60LcmD6UIgb8CEL6U4",
"type": "message",
"role": "assistant",
"content": ["<|audio_text|>"]
}
My AgentSession uses OpenAI Realtime with Azure and ElevenLabs TTS. Any idea what this could be?
That <|audio_text|> is coming from and should be internal to the LLM, but sometimes can leak out.
Rather than trying to adjust the LLM with prompts, it’s probably more reliable to intercept and replace these in a custom llm_node. See this example that removes <think> tags:
async with self._llm.chat(chat_ctx=chat_ctx, tools=tools, tool_choice=None) as stream:
async for chunk in stream:
if chunk is None:
continue
content = getattr(chunk.delta, 'content', None) if hasattr(chunk, 'delta') else str(chunk)
if content is None:
yield chunk
continue
processed_content = content.replace("<think>", "").replace("</think>", "Okay, I'm ready to respond.")
print(f"Original: {content}, Processed: {processed_content}")
if processed_content != content:
if hasattr(chunk, 'delta') and hasattr(chunk.delta, 'content'):
chunk.delta.content = processed_content
else:
chunk = processed_content
yield chunk
the shared link is incorrect
@Ahmed_Aziz apologies for the inconvenience, I have updated the link