Skip to content

fix(amd): start SIP detection after answer#6386

Open
dexhunter wants to merge 1 commit into
livekit:mainfrom
dexhunter:fix/amd-sip-answer-timeout
Open

fix(amd): start SIP detection after answer#6386
dexhunter wants to merge 1 commit into
livekit:mainfrom
dexhunter:fix/amd-sip-answer-timeout

Conversation

@dexhunter

Copy link
Copy Markdown

Summary

  • start the AMD detection budget when an outbound SIP call becomes active, rather than when its early-media track is subscribed
  • add a separate configurable sip_answer_timeout guard, defaulting to 60 seconds, for calls that never become active
  • keep non-SIP behavior unchanged and add lifecycle, timeout, fallback, and public-export coverage

Fixes #6187.

Why

Carrier early media can subscribe the audio track well before answer. On the current implementation, that consumes the default 20-second detection_timeout during ringback and can emit uncertain / detection_timeout before a late-answering person or voicemail becomes active.

This change preserves detection_timeout as a post-answer AMD budget. The new answer guard independently bounds calls that never reach active.

Evaluation

The deterministic harness models a SIP track subscribed at t=0 and a call becoming active at t=32s:

Metric main This PR
detection_timeout_pre_answer_ms 20,000 ms 0 ms

The 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

  • Python 3.10: 27 focused AMD tests passed
  • Python 3.14: 27 focused AMD tests passed
  • make check: formatting, lint, and mypy passed across 617 source files
  • strict evaluator: detection_timeout_pre_answer_ms=0

The 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.

@dexhunter dexhunter requested a review from a team as a code owner July 11, 2026 00:01
@CLAassistant

CLAassistant commented Jul 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AMD: detection_timeout still armed at track subscription poisons long-ring outbound SIP calls (follow-up to #5848)

2 participants