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
Phantom tool call in an extended-thinking turn permanently wedges the session #47274
When a model calls a nonexistent tool during an extended-thinking turn, opencode stores it as an invalid tool part. On the next request that turn is the latest assistant message, and Anthropic rejects every continuation:
messages.N.content.M: `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 session is stuck for good. Only editing storage or starting fresh recovers it.
Why
toModelMessagesEffect (packages/opencode/src/session/message-v2.ts) replays invalid tool parts as normal tool_use/tool_result blocks. They land interleaved between the signed thinking blocks, which breaks the byte-exact thinking replay Anthropic validates. The phantom call was never executed, so replaying it adds nothing but breakage (and re-injects the full tool list, see #41047).
Repro
Anthropic/Bedrock model, extended thinking on.
One turn calls a tool that does not exist (happens with some models / MCP setups).
Continue the session -> permanent 400, "thinking blocks cannot be modified".
Fix
Drop invalid tool parts when building model messages; thinking blocks stay intact. PR incoming.
In v2 a call to a tool that does not exist is kept exactly as the model sent it and answered with an error result saying the tool is not available; there is no longer a rewrite into an invalid tool part. History replay in packages/core/src/session/runner/to-llm-message.ts keeps the assistant's thinking blocks and tool calls in their original order, so the signed thinking is not modified on the next request. To get v2: npm i -g @opencode/cli@latest or curl -fsSL https://opencode.ai/v2/install | bash (desktop: update the app). If you still see this on v2, please open a new issue with the details.
Activity
russrapper15-png commentedon Sep 4, 2026
https://inknaija.com/join?ref=INK-RUSSRAPP-8ZG8AG
neriousy commentedon Oct 19, 2026
In v2 a call to a tool that does not exist is kept exactly as the model sent it and answered with an error result saying the tool is not available; there is no longer a rewrite into an
invalidtool part. History replay inpackages/core/src/session/runner/to-llm-message.tskeeps the assistant's thinking blocks and tool calls in their original order, so the signed thinking is not modified on the next request. To get v2:npm i -g @opencode/cli@latestorcurl -fsSL https://opencode.ai/v2/install | bash(desktop: update the app). If you still see this on v2, please open a new issue with the details.