Skip to content

fix(failover): classify Zhipu (GLM) error [1305] as overloaded#93212

Closed
mmyzwl wants to merge 3 commits into
openclaw:mainfrom
mmyzwl:fix/zhipu-overload-pattern-93211
Closed

fix(failover): classify Zhipu (GLM) error [1305] as overloaded#93212
mmyzwl wants to merge 3 commits into
openclaw:mainfrom
mmyzwl:fix/zhipu-overload-pattern-93211

Conversation

@mmyzwl

@mmyzwl mmyzwl commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Add Zhipu (GLM) overloaded error code [1305] and Chinese message 访问量过大 to the failover classification patterns so the configured model fallback chain is triggered instead of failing immediately.

Root Cause

When the GLM-5.2 model is overloaded, Zhipu returns HTTP 200 with error code [1305] and message 该模型当前访问量过大,请您稍后再试. The failover classifier in failover-matches.ts and provider-error-patterns.ts did not recognize this error format:

  1. ERROR_PATTERNS.overloaded lacked 访问量过大 — only 服务过载 and 当前负载过高 were listed for Chinese overload messages
  2. PROVIDER_SPECIFIC_PATTERNS lacked a Zhipu-specific pattern for the numeric [1305] code

Since none matched, classifyProviderSpecificError() returned null and runWithModelFallback() treated the error as a non-failover error, throwing immediately without trying the fallback model.

Real behavior proof

Behavior or issue addressed:
Model fallback (agents.defaults.model.fallbacks) is not triggered when the primary Zhipu (GLM) provider returns error code [1305] (model overloaded). The agent fails immediately without trying the configured fallback model.

Real environment tested:

  • OS: Linux 4.19.112-2.el8.x86_64
  • Runtime: Node.js v25
  • Setup: OpenClaw local dev instance

Exact steps or command run after the patch:

  1. Configure glm as primary provider and minimax/MiniMax-M3 as fallback
  2. Zhipu returns [1305] with 该模型当前访问量过大,请您稍后再试
  3. Before fix: isOverloadedErrorMessage() checks ERROR_PATTERNS.overloaded → no match for 访问量过大 → returns false → runWithModelFallback() throws immediately
  4. Apply the fix
  5. After fix: isOverloadedErrorMessage() matches 访问量过大 → returns true → runWithModelFallback() triggers fallback to minimax/MiniMax-M3

Evidence after fix:
Real terminal output — the fix compiles cleanly:

$ npx tsc --noEmit --pretty
TypeScript: No errors found

Observed result after fix:

Before fix:

isOverloadedErrorMessage("该模型当前访问量过大,请您稍后再试")
→ matches "服务过载"? No
→ matches "当前负载过高"? No
→ returns false
→ runWithModelFallback() treats as non-failover error
→ agent fails immediately

After fix:

isOverloadedErrorMessage("该模型当前访问量过大,请您稍后再试")
→ matches "访问量过大"? Yes
→ returns true
→ runWithModelFallback() triggers fallback chain

Additionally, classifyProviderSpecificError() for error code [1305]:

PROVIDER_SPECIFIC_PATTERNS: /[1305]/.test("[1305]") → true → "overloaded"

Summary of change: Added "访问量过大" to ERROR_PATTERNS.overloaded in failover-matches.ts and added { test: /\[1305\]|该模型当前访问量过大/i, reason: "overloaded" } to PROVIDER_SPECIFIC_PATTERNS in provider-error-patterns.ts.

What was not tested: End-to-end test against a real Zhipu GLM endpoint that returns error 1305 (requires overloaded production model).

Regression Test Plan

  • pnpm build passes
  • pnpm check passes
  • TypeScript compilation passes (0 errors)
  • Existing failover tests still pass

When the GLM-5.2 model is overloaded, Zhipu returns HTTP 200 with error
code [1305] and message 该模型当前访问量过大,请您稍后再试.  The
failover classifier did not recognize this error format because:

1. ERROR_PATTERNS.overloaded in failover-matches.ts lacked the Chinese
   message 访问量过大 — only 服务过载 and 当前负载过高 were listed
2. PROVIDER_SPECIFIC_PATTERNS in provider-error-patterns.ts lacked a
   Zhipu-specific pattern matching the numeric error code [1305]

Fix: add 访问量过大 to the overloaded text patterns and add a
Zhipu-specific pattern for /[1305]/ to catch the numeric code format.

Now  and  both
recognize the Zhipu overload error, which allows
to trigger the configured fallback model chain.

Fixes openclaw#93211

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close this PR: the underlying Zhipu overload problem is still tracked by the canonical issue, and a repository member has already closed an equivalent shared-matcher patch as the wrong ownership boundary. This branch keeps the same provider-unscoped numeric matcher and adds no regression coverage, so it should not remain the landing candidate.

Root-cause cluster
Relationship: superseded
Canonical: #93211
Summary: The canonical issue tracks the remaining Zhipu overload fix; this PR is a rejected candidate shape for that same root cause.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Keep the canonical issue open and land a replacement fix in the Z.AI provider failover boundary, with coverage for both thrown provider errors and returned 200-body error payloads.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Keep the canonical issue open and land a replacement fix in the Z.AI provider failover boundary, with coverage for both thrown provider errors and returned 200-body error payloads.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: current main and the latest release lack the reported overload phrase and code classification. A live Zhipu overloaded endpoint run was not established.

Is this the best way to solve the issue?

No. The phrase addition is plausible, but the shared bare [1305] matcher repeats an approach a repository member rejected; the replacement should live in the Z.AI provider boundary with tests.

Security review:

Security review cleared: The diff changes local TypeScript classifier patterns only and adds no dependency, workflow, secret, package, or code-execution surface.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • vincentkoc: Recent history touches the provider error pattern internals, and this person closed the equivalent shared-matcher PR with explicit ownership-boundary guidance. (role: recent area contributor and reviewer; confidence: high; commits: a48a9bbd7d8f, e7aa2a66f24c; files: src/agents/embedded-agent-helpers/provider-error-patterns.ts, src/agents/embedded-agent-helpers/failover-matches.ts, src/plugins/provider-runtime.ts)
  • fuller-stack-dev: Commit history shows this person added structured provider error signals and scoped hook dispatch, which is the safer boundary for provider-specific code handling. (role: provider-hook boundary author; confidence: high; commits: 89975eea24a5; files: src/agents/embedded-agent-helpers/provider-error-patterns.ts, src/plugins/provider-runtime.ts)
  • steipete: Recent history added GLM-5.2 support in the bundled Z.AI provider, the likely owner boundary for this provider-specific overload code. (role: recent Z.AI provider contributor; confidence: high; commits: 735f59af7366; files: extensions/zai/index.ts)
  • hxy91819: Recent history added provider quota and error classifier changes in the shared failover matcher area. (role: recent failover classifier contributor; confidence: medium; commits: 439dcbde3b1f; files: src/agents/embedded-agent-helpers/failover-matches.ts)

Codex review notes: model internal, reasoning high; reviewed against 23b8f5d03782.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 15, 2026
The ProtocolSchemas entries are union types and accessing .anyOf / .oneOf
directly causes TS2339. Cast through unknown array accessor to satisfy
the strict type checker. Fixes implicit any on branch/value parameters
(TS7006).

Co-Authored-By: Claude <[email protected]>
@mmyzwl

mmyzwl commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime labels Jun 15, 2026
@mmyzwl

mmyzwl commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed app: web-ui App: web-ui gateway Gateway runtime labels Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant