Tabbit
ResourcesBlogModels
Tabbit LogoTabbit

Tabbit — The AI Browser that Works for You

Topics

  • AI Browser Resources
  • Agentic Browser Resources
  • Browser Downloads and Install Guides
  • Browser Comparisons
  • AI Browser Alternatives
  • Browser Productivity Resources

Popular Guides

  • AI Browser
  • Agentic Browser Download
  • Best AI Browser 2026: Top 9 Tested & Ranked
  • AI Browser Download
  • Free AI Browser
  • Best AI Browser 2026
  • AI Browser Comparison 2026
  • AI Browser for Windows
  • AI Browser for Mac
  • Chrome Alternative 2026

Events

  • Tabbit Skill Competition
  • KPOP SBTI Fandom Personality Test
  • Tabbit Campus Creator Program
  • fifi's Picks: AI Skills for Research Papers
  • User Survey

About

  • Tabbit Blog
  • Press & Media
Prompt guide
CommunityGLM-5.1

GLM-5.1: Claude Code Tool Discovery and System Role Compatibility Workaround

Original source

GitHub zai-org/GLM-5

Authorai7eam-dev / chgwan / stofancy

Source date2026-05-28

Tabbit curation2026-09-08

Read original

One-sentence takeaway

When using GLM-5.1 in Claude Code or a multi-Agent framework, you must explicitly inject tool_reference parsing rules into the system prompt to prevent tool deadlocks, and intercept the system role in messages[] to avoid HTTP 422 errors.

Use cases

  • Suitable tasks: Using the Claude Code CLI, OpenCode, Cline, or Roo Code to drive GLM-5.1 through an Anthropic-compatible interface or local proxy for multi-tool, multi-agent collaboration tasks.

  • Unsuitable tasks: Running complex workflows that include ToolSearch lazy-loaded tools directly with the native Anthropic client without any system-prompt constraints.

  • Applicable model versions: GLM-5.1, GLM-5.2.

  • Applicable clients, Agents, or APIs: Claude Code CLI (2.1.x+), Z.ai API (/api/anthropic), BigModel.cn API, local SGLang/vLLM proxies.

  • Recommended reasoning levels and parameters: Standard Agent parameters; disable the client's unprocessed role: "system" injection, or disable ENABLE_TOOL_SEARCH.

Ready-to-use content

Tool-understanding system prompt for Claude Code / CLAUDE.md

Add the following content to the CLAUDE.md in the project root or to the global system prompt to fix the GLM-5.1 defect where it misinterprets tool_reference as “tool not found” and stops:

## Understanding tool_reference Response Type

When ToolSearch returns a response containing:
{"type": "tool_reference", "tool_name": "<ToolName>"}

This means the tool is now registered and available. You must proceed immediately to invoke the tool directly:
<ToolName>({ ...parameters... })

Never respond with "The tool search didn't return any tool" when a tool_reference block is present.

Claude Code environment variables and configuration workaround

Add the following configuration to the Claude Code configuration file ~/.claude/settings.json or to the environment to avoid ToolSearch loops and endpoint 422 validation failures:

# Option A: Disable lazy tool search directly through an environment variable (preload all tools)
export ENABLE_TOOL_SEARCH=false

# Option B: Configure the Anthropic-compatible endpoint
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-api-key"

Test/workflow steps

  1. Configure GLM-5.1 as the backend model in Claude Code.

  2. Trigger a task involving multiple agents or dynamic tool search (such as ultracode or Workflow).

  3. Check the returned logs: if the prompt above has not been injected, GLM-5.1 will respond “tool not found” and terminate when it receives {"type": "tool_reference", "tool_name": "Workflow"}.

  4. Inject the Markdown above into CLAUDE.md and run the task again to verify that GLM-5.1 correctly recognizes tool_reference and directly initiates a Workflow({...}) call.

  5. If using a plugin that injects a SessionStart hook (such as superpowers), use local middleware to fold the system role messages in messages[] into the top-level system field to prevent the GLM endpoint from returning HTTP 422.

Original evidence and data

  • GitHub Issue #76 records that when the ultracode workflow is triggered in Claude Code, GLM-5.1 cannot natively recognize Anthropic's tool_reference protocol block. In comparative tests, Claude Sonnet 4 and Xiaomi Memo handled it correctly, while GLM-5.1 terminated execution.

  • GitHub Issue #74 records that Claude Code injects {"role": "system", "content": "..."} into the messages[] array. The official Anthropic endpoint folds it normally, but the GLM-compatible endpoint returns HTTP 422: Input should be 'user' or 'assistant'.

Applicability boundaries

  • This workaround targets incompatibilities at the Anthropic protocol and tool-discovery layers; it cannot resolve underlying code-logic errors in the model itself.

  • If the model backend is deployed on self-hosted SGLang/vLLM, you can upgrade directly to the latest branch containing the tool-parsing fix.

Source excerpt or observation (for compliant short quote only)

An Issue contributor noted: “GLM-5.1's training data does not appear to include the tool_reference response type... Adding explicit guidance about tool_reference in the system prompt enables GLM-5.1 to handle it correctly.”

Curated by Tabbit

Prompt material is summarized from public sources and Tabbit editorial notes. Check the original licensing and intended use before copying it.

GLM-5.1

Use in Tabbit

GLM-5.1

Related prompts

MediaZ.AI Developer Document / Z.ai2026-04-07

GLM-5.1: Long-horizon Agent and Claude Code Configuration

CommunityGitHub kvcache-ai/ktransformers2026-04-08

GLM-5.1: SGLang Heterogeneous Deployment and Interleaved Thinking Configuration

Communityreddit.com2026-05-15

GLM-5.1: OpenCode Multi-Model Orchestration and Anti-Overthinking Prompt

GLM-5.1

Related reviews

OfficialZ.ai2026-04-07

GLM-5.1: Z.ai's Official Long-Horizon Engineering Benchmarks and Reproduction Conditions

MediaSerenities AI2026-03-29

GLM-5.1: Serenities AI's Self-Reported Benchmarks and the Boundaries of Independent Validation

CommunityReddit r/LocalLLM

GLM-5.1: Reddit LocalLLM Real-World Coding and Context Experience

MediaArtificial Analysis2026-04-07

GLM-5.1: Artificial Analysis Independent Intelligence Index and Inference Throughput Benchmark