Skip to content

fix(voice): unplayed agent response inserted into chat context on early interruption #1269

@itsnicjohn

Description

@itsnicjohn

Bug

When the user interrupts the agent immediately after the first audio frame is queued but before any text has been synchronized, the full unplayed LLM response is incorrectly inserted into the chat context. This causes the agent to "remember" things it never said.

Example: Agent generates a follow-up question, user interrupts before any audio plays, user asks the agent to repeat its question — agent repeats the question it never actually said.

Root Cause

In agent_activity.ts, forwardedText is initialized to the full generated response (textOut?.text). On interruption:

  • If first audio frame was not played → forwardedText = ''
  • If first audio frame was queued but synchronizedTranscript is empty (interrupted before any text synced) → forwardedText stays as the full unplayed text ❌

Affected locations:

Fix

Add else { forwardedText = ''; } in both locations:

// before
if (playbackEv.synchronizedTranscript) {
  forwardedText = playbackEv.synchronizedTranscript;
}

// after
if (playbackEv.synchronizedTranscript) {
  forwardedText = playbackEv.synchronizedTranscript;
} else {
  forwardedText = '';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions