Skip to content

[Bug]: tool_use blocks missing corresponding tool_result blocks causes API rejection #1748

@kamafozilov

Description

@kamafozilov

Description

When using the plugin, the Anthropic API rejects the request because tool_use blocks are sent without their corresponding tool_result blocks in the following message.

Error

messages.43: `tool_use` ids were found without `tool_result` blocks immediately after:
toolu_012Z2GoLgracmYWaur26knX3, toolu_015dY9D1V5UVaGBhtg4XP41s, toolu_018yzzDMbmqAQHaivCiYAyuJ.

Each `tool_use` block must have a corresponding `tool_result` block in the next message.

Expected Behavior

Every tool_use block in the conversation history should have a matching tool_result block in the immediately following message, per the Anthropic API contract.

Actual Behavior

Three tool_use IDs were present in the message history without their tool_result counterparts at messages.43, causing the API to reject the entire request.

Possible Causes

  • Tool execution results being dropped/lost before being appended to conversation history
  • Race condition when multiple tools execute in parallel — some results may not be collected before the next API call
  • Session serialization/deserialization losing tool_result entries

Related

Environment

  • Plugin: oh-my-opencode
  • API: Anthropic (Claude)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions