Skip to content

fix: accept Anthropic tool_reference blocks as text - #152

Merged
caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
yan-tianshi-shu:fix/anthropic-tool-reference
Sep 14, 2026
Merged

fix: accept Anthropic tool_reference blocks as text#152
caigee-cmd merged 2 commits into
caigee-cmd:mainfrom
yan-tianshi-shu:fix/anthropic-tool-reference

Conversation

@yan-tianshi-shu

Copy link
Copy Markdown

Summary

  • Claude Code's tool search returns tool_reference blocks inside tool_result content, e.g. {"type":"tool_result","tool_use_id":"toolu_1","content":[{"type":"tool_reference","tool_name":"TaskStop"}]}.
  • The translator treats unknown content block types as a hard 400 messages[N]: content[i].content: content[j] type "tool_reference" is not supported. Because the block stays in the conversation history, the session hard-locks: every subsequent request fails with the same 400.
  • Mirror the existing image-block degradation: render tool_reference as a Tool available: <name> text line (with unknown as the fallback when tool_name is absent) instead of rejecting the request. The Qoder upstream has no equivalent block, so text is the lossless-enough representation.

Test plan

  • go test ./... (translate + api packages run against this commit)
  • go vet ./...
  • cd worker && npm test
  • cd frontend && npm run build && npm run lint
  • No tokens, auth blobs, raw captures, or host details in the diff

Verified end to end against a live Claude Code session with ENABLE_TOOL_SEARCH=true: the request that previously 400'd now returns 200 end_turn and the model answers using the referenced tool name.

Zx200 and others added 2 commits September 13, 2026 15:43
Claude Code's tool search returns tool_reference blocks inside tool_result
content. The translator rejected unknown block types with a 400, which hard
locks the session because the block stays in the conversation history.

Render tool_reference as a "Tool available: <name>" text line instead.
@caigee-cmd
caigee-cmd merged commit cae0a30 into caigee-cmd:main Sep 14, 2026
@yan-tianshi-shu
yan-tianshi-shu deleted the fix/anthropic-tool-reference branch September 14, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants