Skip to content

GLM-5.1 fails to understand tool_reference response type in Anthropic-compatible tool use #76

@ai7eam-dev

Description

@ai7eam-dev

Environment

  • Model: glm-5.1
  • API: Anthropic-compatible endpoint (/api/anthropic)
  • Client: Claude Code CLI

Description

When using Claude Code's ToolSearch (deferred tool discovery) feature, GLM-5.1 receives a response containing a tool_reference content block but fails to interpret its meaning, concluding that "no tools were found" instead of proceeding to call the referenced tool.

Reproduction

  1. Configure GLM-5.1 as the backend model in Claude Code (via Anthropic-compatible API)
  2. Trigger an ultracode/multi-agent workflow (e.g., include the keyword "ultracode" in a prompt)
  3. GLM-5.1 calls ToolSearch to discover the Workflow tool
  4. The tool response returns:
{
  "content": [
    {
      "type": "tool_reference",
      "tool_name": "Workflow"
    }
  ]
}
  1. Expected behavior: GLM-5.1 recognizes tool_reference means the tool is available and calls Workflow directly
  2. Actual behavior: GLM-5.1 responds "The tool search didn't return any Workflow tool" and stops execution

Comparison with Other Models

Model Correctly handles tool_reference
Xiaomi Memo (mimo-v2.5-pro) ✅ Yes
Claude Sonnet 4 ✅ Yes
GLM-5.1 No

Root Cause

GLM-5.1's training data does not appear to include the tool_reference response type from Anthropic's tool-use protocol. When a tool_result contains a content block with type: "tool_reference", the model should interpret it as: "this tool is now registered and available for direct invocation." Instead, GLM-5.1 treats it as an unrecognized/empty response.

Workaround

Adding explicit guidance about tool_reference in the system prompt enables GLM-5.1 to handle it correctly:

## Understanding tool_reference Response Type

When ToolSearch returns a response containing:
{"type": "tool_reference", "tool_name": "Workflow"}

This means the tool is now available. Call it directly:
Workflow({script: "...", title: "..."})

I verified at the API level that with this additional system prompt context, GLM-5.1 correctly interprets tool_reference and invokes the Workflow tool as expected.

Suggested Fix

Include tool_reference response type understanding in GLM-5.1's fine-tuning / tool-use training data, so the model natively treats {"type": "tool_reference", "tool_name": "..."} as a signal that the named tool is registered and ready to be called directly — no additional system prompt guidance needed.

Related

  • Claude Code uses deferred tool discovery to reduce token usage. Tools like Workflow, TeamCreate, etc. are not loaded at session start and are discovered on-demand via ToolSearch.
  • The tool_reference type is part of Claude Code's internal tool protocol for signaling that a deferred tool has been loaded.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions