Skip to content

fix(agents): preserve overload wording for rate-limited responses - #98165

Merged
steipete merged 4 commits into
openclaw:mainfrom
SunnyShu0925:fix/http429-overloaded-classify-98101
Jul 6, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
SunnyShu0925:fix/http429-overloaded-classify-98101

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Related to #98101

What Problem This Solves

Z.AI can return HTTP 429 / business code 1305 with the message “temporarily overloaded.” OpenClaw correctly routes that response through rate-limit backoff, but the user-facing formatter previously stopped at the bare 429 token and displayed the generic “API rate limit reached” copy instead of preserving the provider's overload wording.

Why This Change Was Made

User-facing wording and retry classification are separate decisions. The formatter now:

  1. keeps the dedicated model-capacity guidance;
  2. preserves actionable provider retry/reset details when present;
  3. uses the transient overload copy when the response says overloaded but has no more specific timing guidance; and
  4. otherwise falls back to the generic rate-limit copy.

The internal 429 classification remains rate_limit. Z.AI's official error contract defines HTTP 429 as concurrency/frequency/account limiting and business code 1305 as a triggered rate limit; changing it to overloaded would incorrectly alter profile cooldown and fallback behavior.

User Impact

Users now see “The AI service is temporarily overloaded. Please try again in a moment.” for overload-worded Z.AI 1305 responses, while explicit retry windows still surface and documented rate-limit backoff remains intact.

Thanks @SunnyShu0925 for surfacing the overlapping 429/overload formatter path and contributing the original regression coverage.

Evidence

  • Exact prepared head: 0b1b722a1adfb61f284d1e453518b72c089bf777 (exact-head CI).
  • Sanitized direct AWS Crabbox cbx_059970447f01, run run_9d9bfcd2a344: public networking, no Tailscale, no instance role, no credential hydration, and reviewed-SHA pinning.
  • Same run: 444 assertions passed across formatter, sanitizer, failover classification, and model-fallback suites.
  • Official Z.AI error contract: HTTP 429 covers concurrency/frequency/account limiting; code 1305 means the API triggered a rate limit; code 1312 is the distinct model-high-traffic condition.
  • Fresh whole-branch AutoReview found no accepted/actionable findings after preserving explicit retry details (confidence 0.84).
  • Targeted formatting and git diff --check passed.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jun 30, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 30, 2026, 9:55 AM ET / 13:55 UTC.

Summary
The PR reorders agent failover classification so overloaded-worded HTTP 429 bodies classify as overloaded and receive overloaded user-facing copy, with regression coverage for rate-limit and billing cases.

PR surface: Source +16, Tests +59. Total +75 across 3 files.

Reproducibility: yes. Source inspection shows current main matches bare 429 as rate_limit before overloaded and the explicit 429 status branch defaults to rate_limit after billing checks.

Review metrics: 2 noteworthy metrics.

  • Failover decision points changed: 3 changed. The diff changes raw-message classification, explicit HTTP 429 status classification, and user-facing transient error copy.
  • Overlapping candidate PRs: 3 open candidates. Multiple open PRs target the same overloaded-429 root cause, so maintainers should avoid landing duplicate classifier changes.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98101
Summary: This PR is a candidate fix for the canonical HTTP 429 overloaded classification issue, with two overlapping open PRs against the same root cause.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Coordinate with maintainers on which overlapping overloaded-429 PR should be the canonical landing branch.

Risk before merge

  • [P2] Changing overloaded-worded HTTP 429 from rate_limit to overloaded changes auth-profile cooldown, retry, and model fallback routing for affected providers.
  • [P1] Two other open PRs target the same 429-overload root cause, so maintainers should land one canonical implementation and close or supersede the others after merge.

Maintainer options:

  1. Choose One Canonical 429-Overload Fix (recommended)
    Use this PR or one overlapping branch as the landing candidate, then close the duplicate candidate PRs after the chosen fix merges.
  2. Accept The Routing Change
    Maintainers may intentionally accept that overloaded-worded 429s should use overload retry/fallback semantics instead of rate-limit cooldown semantics.
  3. Pause If Another Branch Wins
    If maintainers prefer a different open candidate PR, pause or close this branch after preserving the user-facing copy-path coverage it adds.

Next step before merge

  • No automated repair is needed; maintainer review should choose the canonical overloaded-429 fix branch and let normal merge gates finish.

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

Review details

Best possible solution:

Land one canonical shared classifier/copy fix that preserves model-capacity copy precedence, covers overloaded 429 status and message paths, and keeps the linked issue open until the chosen PR merges.

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

Yes. Source inspection shows current main matches bare 429 as rate_limit before overloaded and the explicit 429 status branch defaults to rate_limit after billing checks.

Is this the best way to solve the issue?

Yes. The shared classifier/status/copy fix is the right layer for provider-agnostic overloaded 429s; a provider-only workaround or message-only reorder would leave either the status path or user-facing copy path broken.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6cb82eaab865.

Label changes

Label justifications:

  • P2: This is a focused provider failover bug fix with real but bounded impact on overloaded 429 handling and user-facing error copy.
  • merge-risk: 🚨 auth-provider: Changing overloaded-worded HTTP 429s from rate_limit to overloaded alters auth-profile cooldown, retry, and model fallback routing.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from direct runtime classifier and copy calls plus focused test output for overloaded, rate-limit, and billing cases.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from direct runtime classifier and copy calls plus focused test output for overloaded, rate-limit, and billing cases.
Evidence reviewed

PR surface:

Source +16, Tests +59. Total +75 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 22 6 +16
Tests 1 60 1 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 82 7 +75

What I checked:

Likely related people:

  • 0xghost42: Authored the merged Zhipu GLM overload matcher and fallback 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 PR and authored the follow-up provider-neutral overload matcher refactor in the same area. (role: recent adjacent refactor author and merger; confidence: high; commits: 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)
  • Pick-cat: Current blame for the affected classifier and copy files points to a broad recent current-main carry-forward commit, though the PR topic was adjacent rather than this exact bug. (role: recent current-main carrier; confidence: medium; commits: eb5fb2aa69f4; files: src/agents/embedded-agent-helpers/errors.ts, src/agents/embedded-agent-helpers/failover-matches.ts, src/agents/embedded-agent-helpers/sanitize-user-facing-text.ts)
  • Maninae: Authored the merged PR that differentiated overloaded and rate-limit user-facing error messages, which is one of the paths this PR updates. (role: user-facing error copy contributor; confidence: medium; commits: 80918d1eae06; files: src/agents/embedded-agent-helpers/sanitize-user-facing-text.ts, src/agents/embedded-agent-helpers/errors.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 30, 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.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 30, 2026
@steipete steipete self-assigned this Jul 6, 2026
@steipete
steipete force-pushed the fix/http429-overloaded-classify-98101 branch from fff2313 to 93c609c Compare July 6, 2026 17:36
@steipete steipete changed the title fix(agents): classify HTTP 429 overloaded bodies as overloaded, not rate_limit fix(agents): preserve overload wording for rate-limited responses Jul 6, 2026
SunnyShu0925 and others added 4 commits July 6, 2026 13:40
…not rate_limit

Reorder overloaded check before rate_limit across all three classification paths:
- classifyFailoverClassificationFromHttpStatus (HTTP status path)
- classifyFailoverClassificationFromMessage (message text path)
- formatRateLimitOrOverloadedErrorCopy (user-facing copy path)

Previously, isRateLimitErrorMessage matched the bare '429' token in
overloaded-worded 429 bodies (e.g. z.ai code 1305), misclassifying them
as rate_limit and showing the wrong user-facing error message. 503/499
already check overloaded before defaulting; 429 now follows the same pattern.

Related to openclaw#98101
…er-facing copy

MODEL_CAPACITY_ERROR_RE is the most specific overloaded variant
('selected model is at capacity') and must be checked before the
broader isOverloadedErrorMessage matcher (which also covers model at
capacity), otherwise it's shadowed with a less specific message.

Related to openclaw#98101
@steipete
steipete force-pushed the fix/http429-overloaded-classify-98101 branch from 93c609c to 0b1b722 Compare July 6, 2026 17:40
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Maintainer fixup complete; this is land-ready at exact head 0b1b722a1adfb61f284d1e453518b72c089bf777.

  • Narrowed the original routing change to the valid defect: overload-worded 429 responses now get truthful transient-overload copy, while internal HTTP 429 handling remains rate_limit per Z.AI's documented contract.
  • Preserved model-capacity guidance and explicit provider retry/reset details before the generic overload copy.
  • Sanitized direct AWS Crabbox proof: public network, no Tailscale, no instance role or credential hydration; lease cbx_059970447f01, run run_9d9bfcd2a344. All 444 assertions passed across formatter, sanitizer, failover classification, and model-fallback suites.
  • Source-blind behavior validation passed for Z.AI 1305 overload wording, explicit retry timing, and model-capacity precedence.
  • Fresh exact-head Codex autoreview: clean, no accepted/actionable findings (confidence 0.89). Targeted formatting and git diff --check: clean.
  • Exact-head CI 28811197401: success, including QA Smoke CI.
  • Repo-native review artifacts validate. Next gate: OPENCLAW_TESTBOX=1 scripts/pr prepare-run 98165.

Thanks @SunnyShu0925 for surfacing the overlapping 429/overload path and contributing the initial regression coverage.

@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Land-ready verification completed on exact head 0b1b722a1adfb61f284d1e453518b72c089bf777.

  • Sanitized direct AWS Crabbox run run_9d9bfcd2a344 used public networking, no Tailscale, no instance role, no credential hydration, and reviewed-SHA pinning.
  • The same run passed 444 assertions across formatter, sanitizer, failover classification, and model-fallback suites.
  • The official Z.AI error contract defines HTTP 429 as limiting, code 1305 as a triggered rate limit, and code 1312 as the distinct model-high-traffic condition. The repaired PR therefore improves display copy without changing 429 cooldown/backoff classification.
  • Fresh whole-branch AutoReview found no accepted/actionable findings after its actionable retry-detail concern was fixed (confidence 0.84).
  • Targeted formatting and git diff --check passed.
  • Exact-head CI is fully green, including QA Smoke CI.

No known proof gaps remain. Separating user-facing copy from failover classification is the best fix: overload wording becomes accurate, explicit retry/reset guidance remains visible, and documented profile cooldown behavior is preserved.

@steipete
steipete merged commit 5f2f06b into openclaw:main Jul 6, 2026
104 checks passed
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…enclaw#98165)

* [AI] fix(agents): classify HTTP 429 overloaded bodies as overloaded, not rate_limit

Reorder overloaded check before rate_limit across all three classification paths:
- classifyFailoverClassificationFromHttpStatus (HTTP status path)
- classifyFailoverClassificationFromMessage (message text path)
- formatRateLimitOrOverloadedErrorCopy (user-facing copy path)

Previously, isRateLimitErrorMessage matched the bare '429' token in
overloaded-worded 429 bodies (e.g. z.ai code 1305), misclassifying them
as rate_limit and showing the wrong user-facing error message. 503/499
already check overloaded before defaulting; 429 now follows the same pattern.

Related to openclaw#98101

* [AI] fix(agents): put MODEL_CAPACITY_ERROR_RE before overloaded in user-facing copy

MODEL_CAPACITY_ERROR_RE is the most specific overloaded variant
('selected model is at capacity') and must be checked before the
broader isOverloadedErrorMessage matcher (which also covers model at
capacity), otherwise it's shadowed with a less specific message.

Related to openclaw#98101

* fix(agents): preserve overload copy for rate-limited responses

* fix(agents): retain provider retry guidance

---------

Co-authored-by: Peter Steinberger <[email protected]>
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants