You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Session permanently fails after compaction when the retained tail starts mid-turn (Claude thinking blocks cannot be modified) #52628
After an auto-compaction that keeps a recent tail, every following request to a Claude model with extended thinking fails with:
messages.1.content.1: `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.
The compaction itself succeeds. The synthetic "Continue..." request fails, and so does every message the user sends afterwards, so the session is stuck.
Cause, from reading dev:
SessionCompaction.select can split the last user turn when it is larger than the tail budget (splitTurn). The tail then starts at an assistant step in the middle of that turn (tail_start_id points to an assistant message).
filterCompacted reorders history to [compaction-user, summary, ...tail, continue-user]. That puts two assistant messages next to each other: the summary and the first tail step.
toModelMessages keeps them as separate assistant messages, and @ai-sdk/anthropic merges consecutive assistant messages into one. The request ends up with assistant: [thinking(summary), text, thinking(tail), tool_use], followed only by tool results and the continue text. Anthropic treats that as the latest assistant turn and rejects it, because the tail's signed thinking now comes after other content.
Because tail_start_id is persisted, the same history is rebuilt on every retry. Other providers don't validate thinking signatures, so it only shows up with Claude. Long agentic turns (many tool steps per user message) hit the mid-turn split most often.
Possibly related: #41738, #39291. Those describe the compaction request itself failing; here the compaction finishes and the requests after it fail.
Fix proposal: insert a short synthetic user message between the summary and a tail that starts with an assistant message. I will open a PR.
Plugins
oh-my-openagent (not involved: its message transform only appends a user turn when history ends with an assistant message)
OpenCode version
1.18.34
Steps to reproduce
Use an Anthropic Claude model with extended thinking (reproduced with an Opus model).
In one user message, let the agent run a long tool loop so that this single turn is larger than the compaction tail budget.
Let auto-compaction run. The stored compaction part has tail_start_id pointing to an assistant message.
The next request (auto "Continue...") fails with the error above, and so does any later message.
This issue might be a duplicate of existing issues. Please check:
#41738: Reports the same thinking-block validation error with extended thinking during compaction; this issue differs in that compaction succeeds and subsequent requests fail.
#39291: Reports mutated signed thinking blocks causing the same validation failure and a persistent retry loop during compaction.
v2 sends the drop_block items so that invalid reasoning should be dropped, also currently this specific failure point should be impossible due to the way compaction currently behaves. Also overall there should be far less errors.
Activity
github-actions commentedon Oct 2, 2026
This issue might be a duplicate of existing issues. Please check:
rekram1-node commentedon Oct 2, 2026
Recommend updating to v2: https://opencode.ai/v2/docs/
v2 sends the drop_block items so that invalid reasoning should be dropped, also currently this specific failure point should be impossible due to the way compaction currently behaves. Also overall there should be far less errors.