I had a telephony voice agent go into a loop conve...
# ask-ai
h
I had a telephony voice agent go into a loop conversation with itself in a single turn. Using Telnyx for phone and sip. What could have caused this?
t
Thanks for reaching out, Roman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding about what could cause a telephony voice agent to loop with itself in a single turn when using Telnyx/SIP, and how to fix it. Likely causes • The agent is hearing its own synthesized speech as input (audio loopback), so it treats its output as new user input and responds again. • Missing or incorrect audio filtering for participant types (SIP vs agent) so the agent doesn’t ignore its own track. • Voice activity detection (VAD) or turn-detection thresholds too sensitive, causing false positives when the agent is speaking. • No or improper noise-cancellation settings for SIP participants, letting TTS playback be captured as inbound audio. Practical fixes to try • Ensure the agent explicitly ignores audio coming from its own participant/track. Configure input processing to only accept audio from the SIP (caller) participant kind. • Enable and apply noise-cancellation tuned for SIP participants (use BVCTelephony where available) so synthesized audio isn’t picked up as user input. • Adjust VAD/turn-detection settings to be less sensitive during agent TTS playback (e.g., require longer silence or higher threshold before treating audio as new input). • If your flow plays prompts back into the same audio path, ensure playback is marked/flagged so the capture pipeline can exclude it. • Add a short safety mute or input-suppression window immediately after the agent speaks to prevent immediate re-capture of TTS. If you’d like, tell me: • whether the agent uses TTS playback through the same SIP audio stream, • which speech/VAD library you’re using, and • whether you can apply BVCTelephony noise-cancellation to SIP participants. I can then suggest exact configuration steps. Sources: Using Noise Cancellation for SIP and WebRTC Participants | How to Enable Agent-to-Agent Speech Detection in LiveKit
h
Here's my AgentSession configs
Copy code
session = AgentSession(
        stt=groq.STT(
            model="whisper-large-v3-turbo",
            language="en",
        ),
        llm="openai/gpt-oss-120b",
        tts="cartesia/sonic-3:6f84f4b8-58a2-430c-8c79-688dad597532",
        turn_detection=MultilingualModel(), 
        vad=ctx.proc.userdata["vad"],
        min_endpointing_delay=0.35,
        max_endpointing_delay=2.0,
        preemptive_generation=True,
        resume_false_interruption=True,
        user_away_timeout=user_away_timeout,
    )
t
Thanks — I’m looking at your AgentSession config and will focus on preventing the agent from hearing its own TTS. A few targeted checks and quick changes to try: 1) Confirm audio routing • Is TTS played back into the same SIP audio stream the STT listens to? If yes, that’s the likely loop source. 2) Ensure the agent ignores its own track • Make STT input selection only accept audio from the SIP participant kind and explicitly exclude the agent/self participant. 3) Apply telephony-specific noise cancellation • Use BVCTelephony (or equivalent telephony noise-cancellation) for the SIP participant’s audio pipeline so TTS playback isn’t captured as inbound speech. 4) Adjust VAD / turn-detection behavior • Your
vad
and
turn_detection=MultilingualModel()
can be tuned: ◦ Increase endpointing delays (raise
min_endpointing_delay
and/or
max_endpointing_delay
) or make VAD thresholds less sensitive so the agent’s short TTS doesn’t trigger a new turn. ◦ Add a short suppression window immediately after TTS playback before STT resumes. 5) Use preemptive generation carefully •
preemptive_generation=True
can cause the agent to start generating while audio is still active; combine with strict input exclusion or suppression windows to avoid regenerating on its own output. 6) Resume/false-interruption protection •
resume_false_interruption=True
helps, but ensure it’s not reinterpreting the agent’s TTS as resumed user speech. Consider increasing debounce timing for resume detection. Next steps for me to give exact config snippets • Tell me whether TTS playback is mixed back into the same SIP send/receive path. • Share what
ctx.proc.userdata["vad"]
contains (VAD thresholds/settings). • Confirm whether you can enable BVCTelephony or apply participant-type filters in your audio pipeline. I can then provide exact code/config changes to stop the loop. Would you like that?