Skip to content

Model fallback not triggered for Zhipu (GLM) error code 1305 — overloaded pattern mismatch #93211

Description

@zhengli0922

Summary

Model fallback (agents.defaults.model.fallbacks) is not triggered when the primary Zhipu (GLM) provider returns error code [1305] with message 该模型当前访问量过大,请您稍后再试 (model overloaded). The agent fails immediately without trying the configured fallback model.

Environment

  • OpenClaw version: 2026.6.5
  • Primary model: glm/GLM-5.2 (Zhipu AI, via Anthropic-compatible API at https://open.bigmodel.cn/api/anthropic)
  • Configured fallback: ["minimax/MiniMax-M3"]
  • OS: Windows 11 + WSL2

Reproduction

  1. Configure glm as primary provider and minimax/MiniMax-M3 as fallback
  2. When GLM-5.2 returns [1305][该模型当前访问量过大,请您稍后再试]
  3. Expected: OpenClaw falls back to minimax/MiniMax-M3
  4. Actual: Agent run fails with LLM request failed, no fallback attempt

Root Cause Analysis

The failover error classifier (classifyFailoverSignalclassifyFailoverClassificationFromMessage) does not recognize the Zhipu error format:

Check Result
HTTP status code (429/503) None — Zhipu returns 200 with error in body
Error code 1305 Not in classifyFailoverReasonFromCode (only matches English codes like RESOURCE_EXHAUSTED, RATE_LIMIT)
isRateLimitErrorMessage No match — "访问量过大" is not in the rate limit patterns
isOverloadedErrorMessage No match — patterns include "当前负载过高" and "服务过载" but not "访问量过大"
PROVIDER_SPECIFIC_PATTERNS No match for [1305] or Zhipu-specific patterns

Since none match, coerceToFailoverError() returns null, and runWithModelFallback() treats it as a non-failover error, throwing immediately.

Suggested Fix

Two changes in src/agents/embedded-agent-helpers/:

1. Add Zhipu overloaded pattern to PROVIDER_SPECIFIC_PATTERNS (in errors.ts)

{
  test: /\[1305\]|访/,
  reason: "overloaded"
}

2. Add Chinese overloaded variants to ERROR_PATTERNS.overloaded (in sanitize-user-facing-text.ts)

"访问量过大",

This ensures both the code-based pattern ([1305]) and the message-based pattern (访问量过大) are caught, classifying the error as "overloaded" which is a recognized failover reason that triggers fallback.

Workaround

Patch node_modules directly (will be lost on npm update):

# In sanitize-user-facing-text-DxQ8sP1D.js, add to overloaded patterns:
"访问量过大"

# In errors-DcOiGp7S.js, add to PROVIDER_SPECIFIC_PATTERNS:
{ test: /\[1305\]|访问量过大/, reason: "overloaded" }

Additional Context

Other Chinese AI providers (e.g. DashScope/Alibaba, Baidu ERNIE) likely have similar Chinese-language error messages that may not match the current English-dominated patterns. Consider a broader audit of Chinese provider error formats.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    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