Skip to content

fix(voice): mute audio input while detached (#2221) - #2231

Closed
toubatbrian wants to merge 2 commits into
mainfrom
brian/fix-warm-transfer-input-detach
Closed

fix(voice): mute audio input while detached (#2221)#2231
toubatbrian wants to merge 2 commits into
mainfrom
brian/fix-warm-transfer-input-detach

Conversation

@toubatbrian

@toubatbrian toubatbrian commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • AudioInput.onDetached() was a no-op, so session.input.setAudioEnabled(false) (used by warm-transfer hold) did not stop frames from reaching STT/LLM/tools
  • Gate the input stream on attach state (matching Python _attached) and sync attach/detach when swapping AgentInput.audio
  • Fixes held-caller speech invoking consult tools and bridging prematurely (#2221)

Test plan

  • Unit: agents/src/voice/io.test.ts — frames drop while detached and resume after re-attach
  • Cue voice E2E (sid_25948c27e48a): hold mute → held speech produces no final STT / no tools → unmute → get_weather works
  • Confirm warm-transfer hold no longer fires connect_to_caller / aliases from caller-room speech

setAudioEnabled(false) called onAttached/onDetached, but AudioInput
treated detach as a no-op, so held warm-transfer callers kept feeding
STT and could invoke consult tools. Gate the input stream on attach
state to match Python.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian
toubatbrian requested a review from a team as a code owner August 5, 2026 22:46
@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a10ba56

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

This PR includes changesets to release 39 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-hedra 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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b466f65cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agents/src/voice/io.ts Outdated
Comment on lines +120 to +121
onDetached(): void {
this._attached = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Decouple the mute gate from overridable hooks

When an application supplies an AudioInput subclass that already overrides onDetached()—a public hook that was a no-op before this change—AgentInput.setAudioEnabled(false) dispatches only to that override unless it happens to call super. The private _attached flag therefore remains true and frames continue into STT, so the mute fix still fails for existing custom inputs. Update the gate through a non-overridable internal transition while invoking the lifecycle hook separately, rather than requiring every existing subclass to add a new super call.

Useful? React with 👍 / 👎.

@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

AgentInput now flips AudioInput attach state through setAttached before
invoking onAttached/onDetached, so subclasses that override those hooks
without calling super still mute. Also align SessionHost forwarded-event
coverage with agent_false_interruption.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian

Copy link
Copy Markdown
Contributor Author

Superseded by #2222 (merged) + follow-up harden/CI fix on this branch. Closing as duplicate.

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