Skip to content

fix(voice): clear forwardedText when interrupted before any text syncs#1270

Merged
u9g merged 1 commit intomainfrom
jl/fix-unplayed-response-chat-ctx
Apr 17, 2026
Merged

fix(voice): clear forwardedText when interrupted before any text syncs#1270
u9g merged 1 commit intomainfrom
jl/fix-unplayed-response-chat-ctx

Conversation

@u9g
Copy link
Copy Markdown
Contributor

@u9g u9g commented Apr 17, 2026

Closes #1269

Description

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

The fix clears forwardedText in the else branch when playbackEv.synchronizedTranscript is empty, rather than letting it retain the initial value of textOut?.text (the full generated response).

Changes Made

  • agent_activity.ts (standard pipeline): clear forwardedText = '' when synchronizedTranscript is empty after first frame was played
  • agent_activity.ts (realtime path): same fix for the realtime generation branch
  • Changeset

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass

Additional Notes

The Python livekit-agents repo has the same structural bug (if synchronized_transcript is not None: without an else) — worth mirroring upstream.


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

When the first audio frame was queued but interruption hit before the
synchronizer produced any text, forwardedText retained the full unplayed
LLM response and was committed to chat context — causing the agent to
'remember' things it never said.
@u9g
Copy link
Copy Markdown
Contributor Author

u9g commented Apr 17, 2026

closes #1269

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 17, 2026

🦋 Changeset detected

Latest commit: 3eb5e1a

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

This PR includes changesets to release 25 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai 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-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero 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

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

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

@u9g u9g merged commit 71bb39e into main Apr 17, 2026
9 checks passed
@u9g u9g deleted the jl/fix-unplayed-response-chat-ctx branch April 17, 2026 01:47
@github-actions github-actions Bot mentioned this pull request Apr 17, 2026
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.

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

2 participants