Repository navigation
fix(amd): settle uncertain when the callee hangs up while listening - #8242
Merged
chenghao-mou merged 6 commits intoNov 12, 2026
Merged
Conversation
Once AMD started listening, a hangup before a verdict left the classifier pending until session teardown closed it, so execute() raised "amd closed before a result was available". AMD now watches the listened participant and settles uncertain (reason=participant_missing) when it disconnects, releasing the verdict right away. Fixes livekit#8241 Assisted-by: Grok Bot
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
I really appreciate your effort in solving the issue. It feels like this PR is close to merging. Do you think we could merge it? 🙏🏼 |
A hangup released any verdict the classifier already held, so execute() interrupted the session and started IVR detection for a callee who had left, and callers tried to leave a voicemail on a closing session. A hangup while listening now settles uncertain with reason=participant_disconnected and replaces a held human, machine-vm or machine-ivr verdict. A held machine-unavailable verdict is still returned: carriers hang up after that announcement, so the hangup confirms it (case reported by kannas14 on livekit#8241). A hangup before listening starts keeps reason=participant_missing. Co-authored-by: kannas14 <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>
main folded tests/test_amd_detector.py into tests/test_amd.py (livekit#8510). The hangup tests and their fake room move there. Co-Authored-By: Claude Fable 5.2 <[email protected]>
`_disconnect_room` read as a verb and `_listened_identity` did not say how it differs from the configured `_participant_identity`. They are now `_room`, as in the other room-holding classes, and `_publisher_identity`, after the `publisher` that `_setup` resolves. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A hangup before the SIP answer reached both the room handler and the SIP-answer wait, so the "call ended before detection could run" line was logged twice. _settle_participant_missing now returns when a result already exists. The handler branch stays: when teardown follows the hangup immediately, it cancels the SIP-answer wait before that wait can settle. Tests now cover a held uncertain verdict, a hangup after an emitted verdict, and the pre-answer hangup against the real SIP-answer wait. Co-Authored-By: Claude Fable 5.2 <[email protected]>
chenghao-mou
approved these changes
Nov 12, 2026
chenghao-mou
added a commit
that referenced
this pull request
Nov 13, 2026
main folded per-PR test files (#8510) and fixed callee hangups in the old AMD classifier (#8242). This branch replaces that classifier, and its detector already completes with reason participant_disconnected, so the old classifier.py and main's tests/test_amd.py are dropped. The branch's edits to the folded test files move to tests/test_audio_recognition.py and tests/test_agent_interruptions.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8241
Once AMD has started listening, a SIP callee who hangs up before a verdict leaves the classifier pending. The participant disconnect then tears the session down,
aclose()closes the classifier, andexecute()raisesRuntimeError("amd closed before a result was available"). Pre-listen hangups already settleuncertainwithreason="participant_missing". This one didn't.Change
_setupresolves the listened participant,AMDsubscribes to the room'sparticipant_disconnected. The handler is removed inaclose().uncertain/participant_missingand callson_end_of_turn()on the classifier. Withwait_until_finishedand speech already heard, a settled verdict is otherwise held until end of turn, so that call releases it right away. If the classifier already holds a verdict that is waiting on the end-of-turn gate, that verdict is the one released.aclose(), andexecute()returns it.Tests
test_execute_settles_when_participant_hangs_up_while_listening: listening starts, speech starts, the participant disconnects, thenaclose()runs. Without the fix it fails withRuntimeError: amd closed before a result was available. With the fix,execute()returnsuncertain/participant_missing.on/off.pytest tests/test_amd_detector.py tests/test_amd_classifier.pypasses (44 tests).ruff format --check,ruff checkandmypy --strictonvoice/amdare clean.AI disclosure: I wrote this fix with help from an AI assistant (Grok Bot). I reviewed the change and ran the tests above myself.