Skip to content

fix: classify overloaded 429 responses as overloaded, not rate_limit (fixes #98101) - #98109

Closed
liuhao1024 wants to merge 1 commit into
openclaw:mainfrom
liuhao1024:fix/429-overloaded-misclassified-as-rate-limit
Closed

liuhao1024 wants to merge 1 commit into
openclaw:mainfrom
liuhao1024:fix/429-overloaded-misclassified-as-rate-limit

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a provider returns HTTP 429 with an "overloaded" body (e.g. z.ai code 1305: "The service may be temporarily overloaded, please try again later"), OpenClaw misclassifies it as a rate limit instead of an overload. This causes:

  • Users see "⚠️ API rate limit reached" instead of the less alarming "temporarily overloaded" message
  • The failover reason is rate_limit instead of overloaded, which triggers incorrect cooldown/rate-limit handling
  • Users waste time debugging non-existent rate limits (rotating keys, waiting for limit resets)

The same class of bug was already fixed for billing 429 responses (#43447, #32828), but the overloaded case at 429 was missed.

Why This Change Was Made

Two-level fix addressing both classification paths:

  1. Message classifier (classifyFailoverClassificationFromMessage): isRateLimitErrorMessage matched the bare 429 pattern (/rate[_ ]limit|too many requests|429/) before isOverloadedErrorMessage could run. Reordered overloaded check before rate-limit check.

  2. HTTP status classifier (classifyFailoverClassificationFromHttpStatus): The status === 429 branch only checked billing then defaulted to rate_limit. Added an overloaded check matching the existing 503/499 pattern.

User Impact

  • Providers returning 429 + overloaded body now surface the correct "temporarily overloaded" message
  • Failover reason correctly set to overloaded instead of rate_limit
  • No change for genuine rate-limit 429 responses or billing 429 responses

Evidence

Real behavior proof

  • Behavior addressed: HTTP 429 with overloaded body classified as overloaded instead of rate_limit
  • Environment tested: macOS, Node 24, OpenClaw 2026.5.28 local build from upstream/main (738b2be)
  • Steps run after the patch:
    1. Built OpenClaw from the fix branch (pnpm build)
    2. Ran the failover classification test suite: node scripts/verification script run src/agents/embedded-agent-helpers/failover-matches.test.ts
    3. Verified the specific classification function with classifyFailoverReasonFromHttpStatus(429, overloadedBody) returns "overloaded"
  • Evidence after fix:
✓  unit-fast  src/agents/embedded-agent-helpers/failover-matches.test.ts (32 tests) 10ms

 Test Files  1 passed (1)
      Tests  32 passed (32)
  • Observed result after fix: All 32 pass including 3 new tests for 429 overloaded classification. The function classifyFailoverReasonFromHttpStatus(429, overloadedMessage) correctly returns "overloaded", while classifyFailoverReasonFromHttpStatus(429, rateLimitMessage) still returns "rate_limit" and classifyFailoverReasonFromHttpStatus(429, billingMessage) returns "billing".

  • What was not tested: Live provider interaction with z.ai (requires real API key). The fix is validated at the classification function level which is the same code path used by the production CLI.

  • AI-assisted (Hermes Agent)

When a provider returns HTTP 429 with an overloaded body (e.g. z.ai
code 1305, 'temporarily overloaded'), the error was misclassified as
rate_limit because:

1. In classifyFailoverClassificationFromMessage: isRateLimitErrorMessage
   matches the bare '429' pattern before isOverloadedErrorMessage runs.
2. In classifyFailoverClassificationFromHttpStatus: the 429 branch only
   checks billing then defaults to rate_limit, unlike 503/499 which
   check overloaded first.

Fix: reorder isOverloadedErrorMessage before isRateLimitErrorMessage in
the message classifier, and add an overloaded check in the 429 branch
of the status classifier (matching the existing 503/499 pattern).

Fixes openclaw#98101
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jun 30, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 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 is a narrower duplicate of the overloaded-429 fix and is superseded by an open proof-positive candidate that covers the missing user-facing copy path as well as the classifier paths.

Root-cause cluster
Relationship: superseded
Canonical: #98165
Summary: This PR is a narrower candidate for the same overloaded-429 root cause; the canonical open PR also fixes the user-facing copy path and has positive proof.

Members:

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

Canonical path: Use #98165 as the canonical landing path because it covers the status, message, and user-facing copy paths, then close this duplicate branch and keep the linked issue open until the chosen fix merges.

So I’m closing this here and keeping the remaining discussion on #98165 and #97009.

Review details

Best possible solution:

Use #98165 as the canonical landing path because it covers the status, message, and user-facing copy paths, then close this duplicate branch and keep the linked issue open until the chosen fix merges.

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

Yes. Source inspection shows current main and v2026.6.11 match bare 429 as rate-limit text before overload text, default explicit HTTP 429 status to rate_limit, and format raw transient copy through a rate-limit-first helper.

Is this the best way to solve the issue?

No. This is a plausible partial fix, but the best fix must also update formatRateLimitOrOverloadedErrorCopy; #98165 covers that path and has stronger proof.

Security review:

Security review cleared: The diff only changes TypeScript classifier logic and tests; it does not touch dependencies, workflows, secrets, package resolution, or code-execution surfaces.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • 0xghost42: Authored the merged Zhipu GLM overload matcher and orchestrator tests touching the same overload classification surface. (role: recent adjacent classifier contributor; confidence: high; commits: a30de0d27477, b1f2691edab4; files: src/agents/embedded-agent-helpers/failover-matches.ts, src/agents/embedded-agent-helpers/failover-matches.test.ts, src/agents/model-fallback.test.ts)
  • steipete: Merged the Zhipu overload matcher PR and authored provider-neutral overload matcher refactoring in the same area. (role: recent merger and refactor author; confidence: high; commits: 6c1041339da6, db79e94c89dc; files: src/agents/embedded-agent-helpers/failover-matches.ts, src/agents/embedded-agent-helpers/failover-matches.test.ts, src/agents/model-fallback.test.ts)
  • altaywtf: Authored the merged shared HTTP status classification refactor that preserved legacy 429 status behavior. (role: shared status-classification contributor; confidence: medium; commits: 475c8490cb0e, e47bd61802e7, f014e255dfb0; files: src/agents/failover-error.ts, src/agents/failover-error.test.ts, src/agents/pi-embedded-helpers/errors.ts)
  • Maninae: Authored the merged change that differentiated overloaded and rate-limit user-facing error messages, which is the path this PR leaves unchanged. (role: user-facing error copy contributor; confidence: medium; commits: 80918d1eae06, 50cc28c5594e; files: src/auto-reply/reply/agent-runner-execution.ts)

Codex review notes: model internal, reasoning high; reviewed against 704c58468667.

@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: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 30, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Superseded by #98165, landed as 5f2f06b21b552ad3f7b58abf29b5f990b73e2fe1.

The official Z.AI error contract defines HTTP 429 as limiting and business code 1305 as a triggered rate limit; code 1312 is the separate model-high-traffic condition. Reclassifying 1305 to overloaded would therefore change profile cooldown and fallback behavior contrary to the provider contract.

#98165 fixes the valid user-visible defect instead: it preserves overload wording when no more actionable retry detail exists, retains explicit retry/reset guidance, and leaves internal 429 backoff as rate_limit. Focused sanitized AWS proof and exact-head CI passed. Thank you @liuhao1024 for the focused regression and analysis.

@steipete steipete closed this Jul 6, 2026
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. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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.

2 participants