Skip to content

feat(barge-in): add default threshold support and drop http transport#1698

Open
chenghao-mou wants to merge 2 commits into
mainfrom
chenghao/feat/barge-in-threshold-and-drop-http-transport
Open

feat(barge-in): add default threshold support and drop http transport#1698
chenghao-mou wants to merge 2 commits into
mainfrom
chenghao/feat/barge-in-threshold-and-drop-http-transport

Conversation

@chenghao-mou
Copy link
Copy Markdown
Member

@chenghao-mou chenghao-mou commented Jun 2, 2026

Description

add default threshold support and drop http transport

Changes Made

  • only pass a threshold to gateway when specified (not possible for the user today)
  • use the default value (in gateway) if not (default and only way)
  • drop the http transport for hosted agents (all traffic goes through gateway with cloud agent identified with worker token)

Needs the gateway and infserve changes deployed first.

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: A small video demo showing changes works as expected and did not break any existing functionality using Agent Playground (if applicable)

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes)

Additional Notes

Python: livekit/agents#5946


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

only pass a threshold to gateway when specified (not possible for the user today)
use the default value (in gateway) if not (default and only way)
drop the http transport for hosted agents (all traffic goes through gateway with cloud agent identified with worker token)
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

🦋 Changeset detected

Latest commit: 0cb9962

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

This PR includes changesets to release 34 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai 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-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld 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-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

Copy link
Copy Markdown
Contributor

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

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.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment on lines +79 to +82
const workerToken = process.env.LIVEKIT_WORKER_TOKEN;
if (workerToken) {
headers['X-LiveKit-Worker-Token'] = workerToken;
}
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.

🟡 LIVEKIT_WORKER_TOKEN only sent when job context exists, but it's a worker-level credential

The LIVEKIT_WORKER_TOKEN header is placed inside the if (ctx) block at agents/src/inference/utils.ts:79-82, meaning it's only included in headers when getJobContext(false) returns a non-null value. However, the worker token is a worker-level environment credential (set by the hosting platform) that should be sent with every request regardless of whether there's an active job context. If AsyncLocalStorage context is lost (possible with Web Streams API async boundaries) or if any request is made outside a job handler, the token won't be included, potentially causing authentication/routing failures in hosted environments.

Prompt for agents
The LIVEKIT_WORKER_TOKEN check at lines 79-82 in agents/src/inference/utils.ts is placed inside the `if (ctx)` block, meaning it's only included when a job context is available. Since this is a worker-level credential (not job-specific), it should be moved outside the `if (ctx)` block so it's always sent when the environment variable is set. Move the workerToken check to after the `if (ctx)` block closes (after line 83), at the same level as the `User-Agent` header setup. The other headers inside `if (ctx)` (room ID, job ID, agent ID) are correctly scoped since they are job-specific.
Open in Devin Review

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

@chenghao-mou chenghao-mou changed the title fix(barge-in): add default threshold support and drop http transport feat(barge-in): add default threshold support and drop http transport Jun 3, 2026
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.

1 participant