ToolSearch tool_reference content type causes API 400 error in long conversations

Resolved 💬 4 comments Opened Feb 26, 2026 by jimmy-evo Closed Mar 1, 2026

Bug Description

When ToolSearch returns a result with type: "tool_reference" in a tool_result content block, it causes a 400 error from the Anthropic API in subsequent turns as the conversation history grows.

Error Message

messages.166.content.0.tool_result.content.0: Input tag 'tool_reference' found using 'type' does not match any of the expected tags: 'document', 'image', 'search_result', 'text'

Steps to Reproduce

  1. In a Claude Code session, trigger a ToolSearch call (e.g., select:Skill)
  2. The tool returns a result containing:

``json
{
"type": "tool_result",
"content": [{"type": "tool_reference", "tool_name": "Skill"}]
}
``

  1. Continue using the session for many turns
  2. Eventually the API returns a 400 error because tool_reference is not a valid content type in tool_result messages

Expected Behavior

ToolSearch results should be serialized into API-compatible content types (e.g., text) before being included in conversation history sent to the API.

Actual Behavior

The raw tool_reference type is included in the conversation history, which the API rejects with a 400 error since it only accepts text, image, document, and search_result content types.

Workaround

Starting a new conversation clears the problematic message history.

Environment

  • Platform: Linux (WSL2)
  • Claude Code: latest

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗