fix(amd): start SIP detection after answer - #6386
Conversation
|
Re-checked this against #6496 arms the detection budget before the publication wait and again at track-up ( I did build the port to check it's workable rather than just asserting it isn't: bound the publication wait directly with @chenghao-mou — on #6187 you said a separate name was fine rather than repurposing
Both are small patches, I just don't think the choice is mine — either way it changes a contract you merged on purpose. Also glad to hold until #6202 lands, since that's rewriting |
|
Thanks for the PR and the follow up! The re-arm of the detection timer was more of a parity port from part of our node.js implementation (https://github.com/livekit/agents-js/blame/c92d739b7d1deefb412255df4f83a993405fe747/agents/src/voice/amd.ts#L413) I think I have an idea: because Something like this:
what do you think? |
|
I opened #6580 with some refactoring and with you as the co-author. Let me know if it addresses your issue. |
|
@chenghao-mou great, thanks, free feel to close my current ones |

Summary
active, rather than when its early-media track is subscribedsip_answer_timeoutguard, defaulting to 60 seconds, for calls that never become activeFixes #6187.
Why
Carrier early media can subscribe the audio track well before answer. On the current implementation, that consumes the default 20-second
detection_timeoutduring ringback and can emituncertain/detection_timeoutbefore a late-answering person or voicemail becomes active.This change preserves
detection_timeoutas a post-answer AMD budget. The new answer guard independently bounds calls that never reachactive.Evaluation
The deterministic harness models a SIP track subscribed at
t=0and a call becoming active att=32s:maindetection_timeout_pre_answer_msThe metric is virtual-time based, so it is independent of CPU speed. The strict harness also checks the default and custom answer deadlines, duplicate timer starts, task cancellation, non-SIP behavior, legacy fallback, and all classifier verdict paths.
Validation
make check: formatting, lint, and mypy passed across 617 source filesdetection_timeout_pre_answer_ms=0The deferred-timer and separate-answer-guard direction was identified through autoresearch with Weco. The final patch was reduced and hardened manually against lifecycle and compatibility counterexamples.