Skip to content

fix(bargein): error when no interruption threshold is known - #6034

Merged
chenghao-mou merged 2 commits into
mainfrom
chenghao/drop-interruption-threshold-fallback
Jun 11, 2026
Merged

chenghao-mou merged 2 commits into
mainfrom
chenghao/drop-interruption-threshold-fallback

Conversation

@chenghao-mou

@chenghao-mou chenghao-mou commented Jun 9, 2026 •

Copy link
Copy Markdown
Member

What

Drops the local THRESHOLD = 0.656 constant from the adaptive interruption detector and errors the stream when no threshold is known.

Why

The server makes the actual interruption decision. The client only ever used THRESHOLD as the last fallback in _resolve_effective_threshold(), which feeds the observability-only effective_threshold debug log. A hardcoded client-side fallback can silently disagree with the server's real default — misleading in exactly the situation you'd be debugging.

When the user doesn't override threshold, the client sends nothing and the server applies its own default; the server-reported default_threshold on session.created is optional. The only genuinely broken case is when both are absent — no user override and no server default — which we now treat as a hard contract violation and fail fast.

Changes

  • Remove the THRESHOLD constant.
  • _resolve_effective_threshold() now returns float | None (user override → server default → None).
  • On session.created with no user override and no server default_threshold, raise a non-retryable APIStatusError (status 500) so the stream fails fast instead of silently running with an unknown threshold.
  • Validate before the observability log, so we don't emit a "session created" line with a null threshold immediately before failing.
  • Update docstring and tests; add TestWsSessionCreatedMissingThreshold covering the fail-fast path.

This is a follow-up cleanup to #5946.

Test plan

  • pytest tests/test_interruption/ — 14 passed
  • ruff check — clean

🤖 Generated with Claude Code

The local THRESHOLD = 0.656 constant only fed the observability-only
effective_threshold log; the server makes the actual interruption
decision. A hardcoded fallback can silently disagree with the server's
real default, which is misleading in exactly the case you'd debug.

Drop the constant: _resolve_effective_threshold now returns None when
neither a user override nor a server default_threshold is known, and we
emit a warning so the unknown-threshold case is surfaced rather than
papered over with a plausible-but-wrong number.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chenghao-mou
chenghao-mou requested a review from a team June 9, 2026 17:24
@chenghao-mou chenghao-mou changed the title fix(bargein): drop client-side THRESHOLD fallback chore(bargein): drop client-side THRESHOLD fallback Jun 9, 2026

@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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

If neither the user nor the server provides a threshold, raise a
non-retryable APIStatusError instead of warning and continuing. Validate
before the observability log so we don't emit a "session created" line
with a null threshold immediately before failing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chenghao-mou chenghao-mou changed the title chore(bargein): drop client-side THRESHOLD fallback fix(bargein): error when no interruption threshold is known Jun 9, 2026

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

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread livekit-agents/livekit/agents/inference/interruption.py
@chenghao-mou
chenghao-mou merged commit 994bb4d into main Jun 11, 2026
24 of 25 checks passed
@chenghao-mou
chenghao-mou deleted the chenghao/drop-interruption-threshold-fallback branch June 11, 2026 12:44
chenghao-mou added a commit that referenced this pull request Jun 11, 2026
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

3 participants