agents icon indicating copy to clipboard operation
agents copied to clipboard

AMD: option to classify in the background without pausing speech playout

Open itogaston opened this issue 1 month ago • 2 comments

Feature Type

Would make my life easier

Feature Description

AMD pauses speech playout authorization as soon as it starts (session._activity._pause_authorization() in AMD._run) and only resumes it when execute() returns a verdict. So the agent cannot say anything until the callee has spoken and the classifier has finished.

For outbound calls where the agent should speak first, this means the human picks up the phone and hears nothing until they say "hello?" themselves (and then still waits for the classifier, see #5616). We tried AMD and removed it for this reason.

What we want is for the agent to be able to speak right away, with AMD analysing in the background, and amd_prediction firing whenever the verdict is ready.

Today it is hard to have both: either the agent speaks first and we cannot tell whether a person or a voicemail picked up, or we know and the agent has to wait for the human to talk.

Workarounds / Alternatives

  • Construct AMD before session.start(): session._activity is still None, so nothing gets paused. This depends on internal ordering, not on a documented behaviour.
  • Call session._activity._resume_authorization() right after starting AMD. This is a private API.
  • Skip AMD and treat consent to recording, or the LLM noticing a voicemail greeting, as the "human answered" signal.

Additional Context

  • livekit-agents 1.8.1, outbound calls via Twilio Elastic SIP Trunking, create_sip_participant(wait_until_answered=True), OpenAI realtime model.
  • Related: #6125 (the need for an AMD signal on SIP calls) and #5616 (the latency execute() adds while playout is paused).

itogaston avatar Oct 09 '26 09:10 itogaston

hello, i would like to work on this

31groot avatar Oct 15 '26 15:10 31groot

Hi, I'm Himanshu, looking for a scoped contribution. I see someone has already offered to work on this. Could I help with tests for speech continuing during classification, followed by a single prediction event and clean cancellation on session close? I'd coordinate with that implementation rather than start a competing one.

I haven't run this reproduction or the candidate PR's tests yet; this is an offer to investigate, not a claim that the gap is confirmed.

himanshumehta avatar Oct 25 '26 04:10 himanshumehta