Skip to content

fix: scope interruption verdicts to agent speech - #2417

Open
chenghao-mou wants to merge 1 commit into
mainfrom
chenghao/fix/AGT-3235-late-verdict-speech-cache
Open

fix: scope interruption verdicts to agent speech#2417
chenghao-mou wants to merge 1 commit into
mainfrom
chenghao/fix/AGT-3235-late-verdict-speech-cache

Conversation

@chenghao-mou

Copy link
Copy Markdown
Member

Late adaptive-interruption responses could outlive one agent speech and resolve an overlap in the next. A missing request-cache entry now invalidates both verdict and inference-result responses instead of recreating state.

Ports livekit/agents#6957. Supersedes #2306, whose author is credited as a co-author.
Fixes #2119
Addresses AGT-3235

Initial prompt and agent context

Model: GPT-5.6

Let's port over livekit/agents#6957 and credit 2306 author as co-author.

create the PR please

Late adaptive-interruption responses could outlive one agent speech and resolve an overlap in the next. Ignore responses after their request cache entry is invalidated at the speech boundary.

Co-authored-by: Manas Srivastava <mastermanas805@gmail.com>
@chenghao-mou
chenghao-mou requested a review from a team as a code owner September 3, 2026 16:27
@chenghao-mou chenghao-mou added node agents review_effort:low Isolated, obvious, and low-risk review labels Sep 3, 2026
@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4e405c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 38 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@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 found 1 potential issue.

Devin Review

Comment on lines +283 to +292
const entry = state.cache.updateValue(createdAt, {
totalDurationInS,
probabilities: message.probabilities,
isInterruption: true,
predictionDurationInS: message.prediction_duration,
detectionDelayInS: (Date.now() - overlapSpeechStartedAt) / 1000,
});
if (!entry) {
logger.trace({ createdAt }, 'ignoring interruption verdict outside the current speech');
break;

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.

🟡 Long overlaps discard valid verdicts

After ten newer requests, updateValue rejects an evicted request even when it belongs to the current speech. Delayed valid verdicts then disappear.

Prompt for agents
The missing-cache-entry check conflates speech-boundary invalidation with normal FIFO eviction. InterruptionStreamBase creates a BoundedCache with capacity 10, while detectionIntervalInS and inferenceTimeout are configurable. A current overlap can therefore evict a still-valid request before its bargein_detected or inference_done response arrives. Track the agent-speech generation independently from bounded request retention, retain pending requests for at least the configured timeout, or size and expire the cache from the request cadence and timeout. Apply the same validity rule to both response types in agents/src/inference/interruption/ws_transport.ts and add a test with more than ten requests in one speech followed by a delayed response for an early request.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Model inference is sticky within a window.

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

Labels

node agents review_effort:low Isolated, obvious, and low-risk review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adaptive interruption: responses are not bound to the overlap they were requested for, so a late bargein can falsely interrupt a later overlap

2 participants