feat(barge-in): add default threshold support and drop http transport#1698
feat(barge-in): add default threshold support and drop http transport#1698chenghao-mou wants to merge 2 commits into
Conversation
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 detectedLatest commit: 0cb9962 The changes in this PR will be included in the next version bump. This PR includes changesets to release 34 packages
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 |
| const workerToken = process.env.LIVEKIT_WORKER_TOKEN; | ||
| if (workerToken) { | ||
| headers['X-LiveKit-Worker-Token'] = workerToken; | ||
| } |
There was a problem hiding this comment.
🟡 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
Description
add default threshold support and drop http transport
Changes Made
Needs the gateway and infserve changes deployed first.
Pre-Review Checklist
Testing
restaurant_agent.tsandrealtime_agent.tswork 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.