glamorous-tiger-25082
12/03/2025, 7:02 AMtall-airline-16756
12/03/2025, 7:02 AMtall-airline-16756
12/03/2025, 7:03 AMmodalities=["text"], the model will produce text and truncation will fail. Use modalities=["audio"] and set a voice if you want audio responses.
• If you want text responses + TTS, keep modalities=["text"] but perform TTS outside the Realtime API (a separate TTS plugin/engine). Handle interruptions at the TTS stream level instead of calling the Realtime truncation API.
• If you sometimes pre-load conversation history, verify that it isn't causing the model to respond in text mode even when you requested audio.
• Add a guard around your interrupt logic so you only call session interrupt/truncate when the current output is audio, and handle unsupported_content_type errors gracefully.
If you share:
• the Realtime model configuration you’re using (modalities, voice),
• whether you load history, and
• the code path where you call interrupt/truncate,
I can point out the exact change to avoid this error. Would you like that?
Sources: OpenAI Realtime API plugin guide | LiveKit docs | Agents (Node.js) | livekit/livekit_composite | DeepWiki | OpenAI and LiveKit partner to turn Advanced Voice into an API | examples/voice_agents | livekit/livekit_composite | DeepWiki | Realtime model plugins | LiveKit Docsglamorous-tiger-25082
12/03/2025, 7:10 AMtall-airline-16756
12/03/2025, 7:10 AMvoice="echo"), and you have transcription enabled. That means the model should produce audio responses — so the truncation error occurs when the session tries to interrupt a response that is actually being sent as non-audio (text).
What to check next
• Confirm the model is actually returning audio frames at runtime. If any messages are coming back as text (tool calls, metadata, or text-only responses) and your code calls interrupt() or truncation the same way, the API will raise that error.
• Verify you are not preloading conversation history that forces text-mode responses.
• Ensure your interrupt logic only calls interrupt() when the current output message has content_type: "audio".
Quick changes to try
• Add a runtime check before truncation:
if current_message.content_type == "audio":
realtime_session.interrupt()
else:
# handle text interruption (e.g., stop TTS or send a follow-up)
• If you sometimes want text + external TTS, explicitly request modalities=["text"] and perform TTS outside the Realtime API; then handle interruptions at the TTS stream level.
If you share:
• a short snippet showing where you call interrupt() and
• whether you load prior messages into the session,
I’ll point out the exact conditional or config change to stop this error. Would you like me to review that snippet?glamorous-tiger-25082
12/03/2025, 7:14 AMvoice="echo"
- NOT explicitly setting modalities parameter (defaults to [“text”, “audio”])
- Location: backend/src/main_new.py, lines 252-260
2. Conversation History:
- NO preloading of conversation history ✅
3. Interrupt Code Path:
- ONE location calling session.interrupt(force=True) in Part 2 timing logic
- Location: backend/src/agents/ielts_examiner_agent_new.py, line 64
- NO content type check before calling interrupt
4. Evidence from Logs:
- Confirmed: Model IS returning text responses despite audio modality request
- Error: “Text message received from Realtime API with audio modality”
- This happens right before the truncation error
Planned Fix:
Implementing Option 1 (add guard around interrupt) + Option 2 (verify Azure voice name and add modalities=[“audio”])tall-airline-16756
12/03/2025, 7:14 AMmodalities=["audio"] when creating the RealtimeModel to avoid text-only responses:
llm = RealtimeModel.with_azure(
azure_deployment="gpt-realtime",
api_version="2024-10-01-preview",
voice="echo",
modalities=["audio"],
input_audio_transcription=InputAudioTranscription(...)
)
1. Guard the interrupt call by content type
• Check the current outgoing message or playback state before calling `session.interrupt(force=True)`:
if current_message.content_type == "audio":
session.interrupt(force=True)
else:
# fallback: stop external TTS or send a follow-up command
Additional fixes (recommended)
• Verify voice="echo" is a valid Azure voice name for your deployment. If it's invalid, the model may fall back to text. Update to a supported voice if needed.
• Add error handling for unsupported_content_type around interrupt calls to avoid uncaught exceptions:
try:
session.interrupt(force=True)
except Exception as e:
if "unsupported_content_type" in str(e):
# handle gracefully (e.g., stop TTS or ignore)
else:
raise
Handling unexpected text responses
• If text responses still appear, stream or convert them to audio via your TTS and control interruptions at the TTS layer instead of calling the Realtime API truncate.
• Log the message content_type and any model metadata when this happens to help triage.
Next step
• If you want, paste the small snippet around line 64 where session.interrupt is called and the code that tracks `current_message`/playback state. I’ll point out the minimal edit to add the guard and error handling.