Skip to content

Fix repeated prompts in opencode acp#53216

Merged
benbrandt merged 3 commits intozed-industries:mainfrom
OmChillure:fix-repeated-prompts-in-opencode-acp
Apr 8, 2026
Merged

Fix repeated prompts in opencode acp#53216
benbrandt merged 3 commits intozed-industries:mainfrom
OmChillure:fix-repeated-prompts-in-opencode-acp

Conversation

@OmChillure
Copy link
Copy Markdown
Contributor

@OmChillure OmChillure commented Apr 6, 2026

Summary

Fixes duplicated Prompts/context in ACP threads after sending a message, as reported in #53201.

Root Cause

The thread already inserts the user prompt optimistically at send time.
If an ACP server also echoes UserMessageChunk updates for the same prompt, the same content is appended again, which can duplicate rendered context sections.

Fix

Ignore echoed UserMessageChunk updates while a turn is actively running, so user prompt content is not appended twice.

Validation

  • Reproduced with OpenCode ACP flow from the issue.
  • Confirmed duplication appears after send (not in the input box).
  • Confirmed duplicate Prompts/context no longer appears with the fix.

Video

Screencast.from.2026-04-06.08-21-32.webm

Self-Review Checklist

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #53201

Release Notes:

  • Fixed duplicated Prompts/context in ACP conversations when servers echo user message chunks after send.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 6, 2026
@zed-community-bot zed-community-bot Bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Apr 6, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator Bot requested review from a team, maxbrunsfeld and probably-neb and removed request for a team April 6, 2026 03:02
// Some ACP servers echo user chunks back over updates, which would duplicate
// context chips/message text unless ignored while a turn is active.
if self.running_turn.is_none() {
self.push_user_content_block(None, content, cx);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to do some check of if we are currently in a user mesage and if the content would match the current message?

Copy link
Copy Markdown
Contributor Author

@OmChillure OmChillure Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the logic and ran the same test already present

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially too "fuzzy" a match.. but given that they will probably replay the whole thing probably ok

@shinobijs
Copy link
Copy Markdown

OpenCode agent started to behave differently after the recent update that caused the duplicate prompt. My first impression was that the changed behaviour was caused by the duplicate prompt. But the agent also seems to have lost file references. This is an issue to be able to instruct the agent to read or update a specific file.

ZED agent has the file name (see below)
image

OpenCode agent has the file content.
image

@benbrandt benbrandt enabled auto-merge (squash) April 8, 2026 18:38
@benbrandt benbrandt merged commit 08e43ae into zed-industries:main Apr 8, 2026
31 checks passed
piper-of-dawn pushed a commit to piper-of-dawn/zed that referenced this pull request Apr 25, 2026
### Summary
Fixes duplicated Prompts/context in ACP threads after sending a message,
as reported in zed-industries#53201.

### Root Cause
The thread already inserts the user prompt optimistically at send time.
If an ACP server also echoes UserMessageChunk updates for the same
prompt, the same content is appended again, which can duplicate rendered
context sections.

### Fix
Ignore echoed UserMessageChunk updates while a turn is actively running,
so user prompt content is not appended twice.

### Validation
- Reproduced with OpenCode ACP flow from the issue.
- Confirmed duplication appears after send (not in the input box).
- Confirmed duplicate Prompts/context no longer appears with the fix.

### Video 

[Screencast from 2026-04-06
08-21-32.webm](https://github.com/user-attachments/assets/33075312-9af7-4dd5-a2a3-5e1169b80243)


### Self-Review Checklist
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#53201

## Release Notes
- Fixed duplicated Prompts/context in ACP conversations when servers
echo user message chunks after send.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompts repeated twice when using certain ACPs.

5 participants