Skip to content

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

Closed

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

  1. lu-zero commented on Aug 27, 2026

    @lu-zero
    ContributorAuthor

    #23298 apparently was never addressed and this is a symptom

  2. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    V2 has no tool-call repair step, so provider-executed tool calls are no longer rewritten to the client-side invalid tool. Anthropic server_tool_use blocks are identified as provider-executed directly from the response and are sent back as server tool calls in later requests. 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.

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