Reusable Realtime Session across Handoffs & Agent Tasks#1193
Reusable Realtime Session across Handoffs & Agent Tasks#1193toubatbrian wants to merge 6 commits intobrian/reuse-sttfrom
Conversation
🦋 Changeset detectedLatest commit: dd61a2a The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 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 |
💡 Codex ReviewLines 960 to 963 in 58726f4
agents-js/agents/src/voice/agent_activity.ts Lines 829 to 830 in 58726f4 The new realtime agents-js/agents/src/stream/deferred_stream.ts Lines 87 to 89 in 58726f4
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
| } catch (e) { | ||
| this.logger.error('failed to say text: %s', String(e)); | ||
| this.agentSession._updateAgentState('listening'); | ||
| return; |
There was a problem hiding this comment.
🟡 realtimeSayTask error handler unconditionally sets agent state to 'listening' ignoring queued speeches
When this.realtimeSession.say() throws in realtimeSayTask, the catch block at line 2892 unconditionally calls this.agentSession._updateAgentState('listening'). This doesn't check whether there are other speeches queued or currently playing, unlike the established pattern in onPipelineReplyDone (agents/src/voice/agent_activity.ts:1577-1581) which checks !this.speechQueue.peek() && (!this._currentSpeech || this._currentSpeech.done()) before transitioning to 'listening'.
If say() is called and fails while other speeches are queued (e.g., from a concurrent generateReply), the agent state would briefly and incorrectly transition to 'listening' before the next queued speech corrects it to 'speaking'.
| } catch (e) { | |
| this.logger.error('failed to say text: %s', String(e)); | |
| this.agentSession._updateAgentState('listening'); | |
| return; | |
| } catch (e) { | |
| this.logger.error('failed to say text: %s', String(e)); | |
| this.onPipelineReplyDone(); | |
| return; |
Was this helpful? React with 👍 or 👎 to provide feedback.
No description provided.