Voice: record spoken replies in the chat and let the agent work while audio plays - #4011
Closed
eddiemachaalani wants to merge 1 commit into
Closed
eddiemachaalani wants to merge 1 commit into
eddiemachaalani wants to merge 1 commit into
Conversation
… playback The speak tool blocked until the client confirmed playback, and the transcript entry was only written afterwards. Two failure modes fell out: the agent sat frozen for the full spoken duration before starting any work (think -> speak -> silence -> work), and when synthesis or playback failed the reply vanished entirely - voice failed silently with nothing to read. speak now emits the assistant transcript entry up front, so the chat always carries the reply as a readable fallback and durable record. It queues playback on a per-session chain - utterances play in order, and a barge-in drains the queue through the existing abort path - and returns once the utterance is queued so the agent keeps working while audio plays. Playback failure surfaces as an error entry pointing at the text. The voice-mode prompt now tells the model the spoken text is recorded (no duplicate text messages) and to continue working while audio plays. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
11 tasks
Collaborator
|
Closing in favor of the app-wide voice implementation in #4157, which is still open. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two voice-mode failure modes, both hit in real use:
speakhandler awaited playback confirmation from the client, so the agent could not start any work until the audio finished playing on the phone. The observed flow was: think → speak → silence while the audio plays → then the first tool call. For a multi-sentence acknowledgment that's many seconds of dead time before work begins.Change
speakis now "a chat message that also plays as audio":speakcalls play in spoken order, and a barge-in drains the queue through the existing abort path.QA evidence
Live on a daemon running this branch, driven from the iOS app: the acknowledgment audio plays while the agent's shell commands are already streaming — previously work only started after the audio ended. Text for every utterance appears in the chat at speak time.
Tests — 4 new, in
voice-session.test.ts:Mutation-checked: restoring the old blocking behavior (
await this.speechQueuein the handler) turns 3 of them red (timeouts, exactly the old freeze); reverting goes green. Typecheck and lint clean.Platforms
Server-only change. Tested on a macOS daemon end-to-end from the iOS app. Not separately tested: Android app (no client change), Windows/Linux daemons (no platform-specific code involved).
Happy to adjust semantics (e.g., a queue-depth cap on pending utterances) if you'd rather different behavior here.
🤖 Generated with Claude Code