Skip to content

Fix duplicate assistant messages when streaming is enabled#381

Closed
ishaanrajiv wants to merge 1 commit intopingdotgg:mainfrom
ishaanrajiv:fix/issue-streaming-duplicate-messages
Closed

Fix duplicate assistant messages when streaming is enabled#381
ishaanrajiv wants to merge 1 commit intopingdotgg:mainfrom
ishaanrajiv:fix/issue-streaming-duplicate-messages

Conversation

@ishaanrajiv
Copy link
Copy Markdown

@ishaanrajiv ishaanrajiv commented Mar 7, 2026

Disclaimer: Generated via T3Code

Fixes #349.

Summary

When Stream assistant messages is enabled, assistant responses can appear twice in the desktop app.

This happens when:

  • assistant text is emitted incrementally from streaming deltas
  • item.completed later arrives with payload.detail containing the full response
  • the completion path treats that detail as fallback text even though content was already streamed

Fix

  • track whether assistant text has already been emitted for a given message
  • only use item.completed.detail as fallback when no assistant text was previously emitted
  • keep normal completion behavior unchanged for non-streamed or fallback-only cases

Validation

  • added a regression test covering streamed deltas followed by item.completed.detail
  • build and tested locally

Before:
Screenshot 2026-03-07 at 7 36 25 PM

After:
Screenshot 2026-03-07 at 7 36 32 PM

- track whether assistant text was already emitted per message
- finalize with buffered text first; ignore completion detail if already streamed
- add regression test for streaming + item.completed detail dedupe
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 7, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aea3a42c-e37f-4677-8d67-6bb70200facc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@maria-rcks
Copy link
Copy Markdown
Collaborator

#465

@maria-rcks maria-rcks closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Responses duplicate when Stream assistant messages is on

2 participants