Repository navigation
Description
Summary
Over ACP, a single assistant response arrives as many tiny agent_message chunks interleaved with agent_thought_chunk updates (one per reasoning delta). Clients that render each chunk as its own block (Zed) show the response fragmented into one-line fragments separated by "Thinking" chips. Claude Code over the same ACP client does not interleave thought chunks mid-text, so the problem is specific to opencode's emission pattern.
Environment
- opencode version: 2.4.1 (latest channel)
- OS: Windows 10/11 (Windows_NT 10.0.26200, win32 x64)
- Terminal: n/a — ACP client is Zed (Zed-industries ACP integration)
- Shell: Git Bash
- Install/channel: latest
- Active plugins: @slkiser/[email protected], local fast-compaction plugin
- Model: GLM (z.ai) via custom providers — streams
reasoning_contentand content alternately
Reproduction
- Configure Zed to use opencode as its ACP agent.
- Start a session on a model that streams reasoning (GLM 5.3 family).
- Ask any question that produces a multi-sentence answer.
Expected Behavior
The assistant's text streams as one growing block; reasoning is rendered separately, without breaking the text into fragments.
Actual Behavior
The text arrives as alternating agent_message / agent_thought_chunk session updates, e.g. (Zed transcript):
first sentence of the answer ends here
💭 Thinking
the next sentence arrives
💭 Thinking
as a separate block, and so on
Zed merges only consecutive same-kind chunks (crates/acp_thread/src/acp_thread.rs, can_merge_message_chunks), so every interleaved thought chunk starts a new text block. The full text is present and in order — this is a rendering/emission mismatch, not data loss. Claude Code over the same client does not emit thought chunks mid-text, so its output renders as one block.
Additional Context
- Started recently (after an opencode 2.x update); before that the same setup rendered normally.
- opencode's own TUI renders these responses as a single block, so the interleaving is specific to the ACP adapter.
- Two possible fixes on opencode's side: buffer reasoning deltas instead of emitting one
agent_thought_chunkper delta, or avoid interleaving thought updates between text deltas of the same response. - Consistently reproducible with reasoning-streaming models; not reproducible via Claude Code as the ACP agent.
Activity
opencodejr commentedon Nov 25, 2026
Thanks for the detailed report. I tried this with a local mock OpenAI-compatible server configured as a custom provider. It streams
reasoning_contentandcontentalternately, as you describe GLM doing. I droveopencode acpwith a minimal ACP client.What I saw:
agent_thought_chunkandagent_message_chunkupdates in that same alternating order. When the model sends all its reasoning first, there is one thought chunk followed by one text chunk.dev(64324cf): same, still interleaved.So OpenCode passes reasoning and text through in the order the provider streams them. Thought chunks and text chunks carry different
messageIds (<message>:reasoning:0and<message>). That looks like the current design rather than something broken, and I couldn't confirm it as a regression. Buffering reasoning, or not interleaving it within a response, would be a change to that behaviour, so it might be better tracked as a feature request for the ACP adapter.If you saw it work in a specific earlier 2.x version with the same GLM setup, it would help to know:
flupkede commentedon Nov 25, 2026
I can't say that it started with that specific version I only started noting this since last week, however opencode, acp and zed received updates so difficult to know what exactly caused it, it 's also not consistent, however once it starts it continues doing so. I thought it would be in the acp layer , because zed just streams what it gets in sequence, so if the text stops and switches message id zed creates the appropriate UI component and continues streaming until the next type of message comes in. Opus said that behavior is fine in Zed, so that it had to be changed in opencode , why it didn't think it was the acp I don't know, because that was my first thought.
opencodejr commentedon Nov 25, 2026
Thanks for the extra details. I think you're right that the place to change this is OpenCode's ACP layer.
In my tests the ACP adapter sends each text delta as an
agent_message_chunkand each reasoning delta as anagent_thought_chunk, in the order they arrive. The core first groups deltas into ~100 ms batches. When a model like GLM alternates reasoning and text mid-answer, Zed therefore gets alternating chunk types, starts a new block at each switch, and the answer ends up in fragments.I used a mock provider that alternates reasoning and text, and saw the same thing on 2.3.2, 2.4.1 and the latest
dev. On 2.3.2 it was intermittent, because how much interleaving shows depends on the stream's timing. That fits what you describe: inconsistent, but once the model starts alternating, it keeps going. I didn't find a version that behaved differently, so this looks like how the adapter works today rather than something that broke.I'm treating this as a feature request: over ACP, keep one response's text as one block, for example by buffering reasoning deltas or not sending thought chunks in the middle of a response's text. The maintainers will consider it. This can't be done as a plugin, because I didn't find a plugin hook that can reorder or merge the updates sent to ACP clients.
flupkede commentedon Nov 25, 2026
however the acp layer for zed is a separate layer right ? or is this also part of opencode I don't think so, so maybe it needs to be tweaked there instead ? Opus said that normally it should send these chunks in one piece and should not switch in between