Repository navigation
Fix/98101 429 overloaded classification - #98202
hanZeng-08 wants to merge 2 commits into
Conversation
…_limit HTTP 429 responses that explicitly contain "overloaded" (e.g. z.ai code 1305) were misclassified as rate_limit because the 429 token matched the broad rate-limit pattern before the overloaded check ran. Check overloaded first for 429 messages in both classification and user-facing copy paths. Fixes openclaw#98101
Security-sensitive changes are blockedOpenClaw does not accept security-sensitive file changes through PRs unless a repository admin or security explicitly authorizes the current head SHA. Detected security-sensitive changes:
If this PR intentionally needs these changes, ask a repository admin or member of The action will approve the current head SHA ( |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close this PR as superseded: it targets a real bug, but a cleaner open canonical PR covers the same status/message behavior plus the user-facing copy path, has proof-sufficient review state, and avoids this branch's unrelated security-sensitive Root-cause cluster 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 for the overloaded-429 fix, then close the linked issue and duplicate PRs after it merges. So I’m closing this here and keeping the remaining discussion on #98165. Review detailsBest possible solution: Use #98165 as the canonical landing path for the overloaded-429 fix, then close the linked issue and duplicate PRs after it merges. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection and the linked issue logs show that current main checks generic 429/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? No for this PR as the landing branch. The failover change is plausible, but #98165 is a cleaner proof-positive candidate covering the same bug without the unrelated ignore-file churn. Security review: Security review needs attention: The PR touches
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 6cb82eaab865. |
|
ClawSweeper applied the proposed close for this PR.
|
Fixes #98101
Summary
Fixes issue #98101: when a provider returns HTTP 429 with a body that explicitly says "overloaded", OpenClaw misclassified it as⚠️ API rate limit reached. Please try again later.". It now correctly classifies as
rate_limitand showed users "overloadedand shows "The AI service is temporarily overloaded. Please try again in a moment.".Real Behavior Proof
Before the fix, the new regression test failed on the old code:
The user-facing copy also returned the rate-limit message on the old code:
After the fix, all related tests pass:
$ pnpm test src/agents/embedded-agent-helpers Test Files 6 passed (6) Tests 91 passed (91)Negative control: a real rate-limit 429 is still classified as
rate_limit(existing testrate limit still classified correctlypasses).Regression Test Plan
Added the following tests in
src/agents/embedded-agent-helpers/failover-matches.test.ts:classifies a 429 body with overloaded text as overloaded— verifiesclassifyFailoverReasonreturnsoverloadedfor z.ai 1305-style responses.returns overloaded user-facing copy for a 429 body with overloaded text— verifiesformatRateLimitOrOverloadedErrorCopyreturns the overloaded user copy.Root Cause
classifyFailoverClassificationFromMessage,isRateLimitErrorMessagewas checked beforeisOverloadedErrorMessage. BecauseERROR_PATTERNS.rateLimitcontains a429wildcard, any non-billing 429 message hit the rate-limit branch first.classifyFailoverClassificationFromHttpStatusunconditionally returnedrate_limitat the end of itsstatus === 429branch, overriding the message-level classification.formatRateLimitOrOverloadedErrorCopyalso checkedisRateLimitErrorMessagefirst, so users saw the rate-limit copy.Implementation Plan Details
classifyFailoverClassificationFromMessage, preferoverloadedwhen the leading HTTP status is 429 andisOverloadedErrorMessagematches.classifyFailoverClassificationFromHttpStatus, checkisOverloadedErrorMessagebefore returningrate_limitfor status 429.formatRateLimitOrOverloadedErrorCopy, returnOVERLOADED_ERROR_USER_MESSAGEfirst when the leading status is 429 and the message is overloaded.Change Details
src/agents/embedded-agent-helpers/errors.tsclassifyFailoverClassificationFromMessage: added 429 + overloaded priority check.classifyFailoverClassificationFromHttpStatus: added overloaded check in the 429 branch.src/agents/embedded-agent-helpers/sanitize-user-facing-text.tsformatRateLimitOrOverloadedErrorCopy: added 429 + overloaded priority check.src/agents/embedded-agent-helpers/failover-matches.test.tsTest Points
overloadedrate_limit(unchanged)isOverloadedErrorMessageNext Steps
Environment: Linux, Node 22.23.1, pnpm 11.2.2