anomalyco / anomalyco/opencode
repairToolCall rewrites provider-executed tool calls to "invalid", breaking the rest of the Anthropic session
@nexxeln is already working on this.
Since Aug 26, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
packages/opencode/src/session/llm.ts:296 — present on dev, v1.17.7, and v1.18.21.
experimental_repairToolCall's fallback rewrites any unrepairable call to the client-side invalid tool. For a provider-executed call that is the wrong move twice over: the call wasn't a hallucinated name, and the rewrite mutates the assistant message. Anthropic then rejects every subsequent request in the session, because the signed thinking sibling no longer matches the block it was signed with — one unknown tool call turns into a hard 400 for the remainder of the conversation.
We hit this via a provider bug (@ai-sdk/anthropic omits dynamic: true on tool_search_tool_*, filed separately), but the repair path is independently wrong: repair exists for the model inventing a tool name, and a providerExecuted call is by definition not that.
ai passes the raw tool call to the hook, so failed.toolCall.providerExecuted is available (ai/dist/index.mjs:3524) — declining to repair when it is set, and rethrowing instead, keeps the transcript intact.
Not the same defect as #41738; that one is about compaction.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.