Skip to content

repairToolCall rewrites provider-executed tool calls to "invalid", breaking the rest of the Anthropic session #45261

Description

@lu-zero

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions