Skip to content

Voice agent always on streaming mode to support barge in - #326165

Merged
Megan Rogge (meganrogge) merged 3 commits into
microsoft:mainfrom
mirimadahmed:mirimadahmed-microsoft-voice-always-on-streaming
Jul 16, 2026
Merged

Megan Rogge (meganrogge) merged 3 commits into
microsoft:mainfrom
mirimadahmed:mirimadahmed-microsoft-voice-always-on-streaming

Conversation

@mirimadahmed

@mirimadahmed Mir (mirimadahmed) commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #326159 (voice barge-in protocol cleanup). This PR sits on top of that branch and should merge after it — its first commit is #326159's, and the net change is the single commit Voice hands-free: stream mic during playback for backend barge-in. Once #326159 lands, that commit drops out of this diff.

What

In hands-free voice mode (agents.voice.handsFree), keep the microphone streaming while the assistant is speaking so the backend's server-VAD can detect the user talking over it (barge-in) — without requiring the user to hold the push-to-talk button.

Why

After the #326159 cleanup the mic is off during assistant playback, so the backend receives no audio while it speaks and true hands-free barge-in is impossible — only a manual button interrupt works.

How

Adds _startBargeInListen() to VoiceSessionController. During playback (hands-free only) it opens a passive, non-interrupting PTT turn that reuses the warm mic and streams frames using the standard PTT protocol (ptt_start / ptt_audio_chunk / ptt_end) — not the removed barge_in_* channel. The backend's _handle_ptt_audio_chunk() runs VAD and, on real speech, cancels its TTS and emits barge_in (already wired to _interruptAssistantPlayback).

Key properties:

  • Does not stop playback, clear the audio queue, or suppress incoming audio — a silent user never disturbs the reply.
  • If the user stays silent, the open turn seamlessly becomes the next listening turn when playback ends (onPlaybackStopped sees _pttHeld).
  • Non-hands-free (manual PTT) mode keeps its prior suppressUntil(+800) behavior unchanged.

Testing

  • VoiceClientService unit tests pass (barge-in events + PTT protocol).
  • npm run typecheck-client clean.
  • Manually verified against the live backend: talking over a long spoken reply stops the assistant and transcribes the barge-in utterance.
Remove the unsupported outbound barge_in monitor messages and keep microphone streaming on the established PTT protocol. Clear playback suppression when PTT starts so backend VAD receives interruption audio immediately, while preserving the inbound barge_in playback cancellation event.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7972bf67-b7f5-4937-9ea8-b1b9a9f13e0d
Copilot AI review requested due to automatic review settings July 16, 2026 14:45

Copilot AI 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.

Pull request overview

Replaces the dedicated barge-in monitoring protocol with continuous PTT streaming during hands-free playback.

Changes:

  • Starts passive PTT streaming while responses play.
  • Removes legacy barge-in monitor APIs and messages.
  • Adds outbound PTT protocol coverage.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
voiceClientService.test.ts Tests outbound PTT messages.
common/voiceClientService.ts Removes barge-in methods.
voiceSessionController.ts Implements passive PTT barge-in listening.
browser/voiceClientService.ts Removes legacy barge-in messages.
micCaptureService.ts Removes dedicated monitor capture support.
In hands-free mode, keep the mic streaming while the assistant speaks by
opening a passive, non-interrupting PTT turn (_startBargeInListen) reusing
the warm mic. This lets the backend's server-VAD hear the user talk over
the assistant and emit speech_started / barge_in (already wired to stop
TTS). If the user stays silent the turn simply becomes the next listening
turn once playback ends. Non-hands-free (manual PTT) keeps its prior
suppressUntil behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e3a8372-08f2-4a5b-bdf4-ed2a29be4622
@mirimadahmed
Mir (mirimadahmed) force-pushed the mirimadahmed-microsoft-voice-always-on-streaming branch from b90ce51 to fd63c05 Compare July 16, 2026 14:51
…sten

The passive barge-in turn opened during assistant playback previously set
`_pttToggleMode = true`. Pressing the mic button mid-playback then hit
`pttDown()`'s toggle branch, which sent `ptt_end` and finalized the turn
WITHOUT stopping playback — leaving the assistant talking and the manual
interrupt broken.

Track the passive listen with a dedicated `_bargeInListenActive` flag
instead. An explicit `pttDown()` now promotes that live stream into a
user-driven interrupt on the SAME turn (no second `ptt_start`, no mic
re-acquire): it stops playback, drops queued audio, opens the user turn,
re-anchors hold telemetry, and moves to listening. Releasing the button
flows through the normal `pttUp()` path.

If the user stays silent through playback, `onPlaybackStopped` converts
the passive turn into a normal tap-to-stop listening turn (toggle mode +
server-VAD auto-end). The flag is cleared in `_finishPtt()` and
`disconnect()` for hygiene.

Addresses the Copilot review comment on microsoft#326165.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e3a8372-08f2-4a5b-bdf4-ed2a29be4622
@meganrogge Megan Rogge (meganrogge) added this to the 1.130.0 milestone Jul 16, 2026
@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) July 16, 2026 17:53
@meganrogge
Megan Rogge (meganrogge) merged commit db30410 into microsoft:main Jul 16, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

6 participants