Repository navigation
fix: stop repeating HTTP 400 requests with transient inner codes - #159221
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 10:44 PM ET / September 27, 2026, 02:44 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch prevents same-model retries for certain rejected HTTP 4xx requests whose only transient signal is an inner error code, while retaining their failover reason and adding classifier and recovery tests. Merge readiness✅ Ready for maintainer review The fix remains absent from current main and has convincing before-and-after Gateway proof. The previously flagged compatibility tradeoff has been explicitly accepted by a repository maintain-permission holder. The linked report’s error-copy concern remains separate. Priority: P1 Review scores
Verification
How this fits togetherProvider failures enter OpenClaw’s failover classifier as HTTP status, code, and error text. The embedded agent runner uses that classification to retry, rotate credentials, try a configured fallback, or surface an error. flowchart LR
A[Provider HTTP failure] --> B[Status, code, and message]
B --> C[Failover classification]
C --> D{Same-model retry eligible?}
D -->|Yes| E[Retry current model]
D -->|No| F[Profile or model fallback]
F --> G[Result or visible error]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +64, Tests +100. Total +164 across 7 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Land the bounded retry fix after normal gates complete, then address the linked report’s misleading prompt-size error copy with sanitized, actionable guidance. Do we have a high-confidence way to reproduce the issue? Yes, with high confidence: the reported HTTP 400 shape follows current main’s code-to-rate-limit path, and the PR records measured baseline and patched Gateway turns. This read-only review did not execute that flow. Is this the best way to solve the issue? Yes for the repeated-request defect: separating retry eligibility from the failover reason preserves fallback and presentation behavior while stopping futile same-model retries. The misleading error copy needs separate work. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9447cc6685d6. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Maintainer decision (Ayaan): accepting the broader retry policy: a 4xx (other than 408/409/410/429/499) whose only transient signal is a generic inner code (rate_limit/overloaded/timeout) no longer retries the same model and falls back immediately; throttling prose, provider-owned signals and Bedrock ThrottlingException still retry. |
|
@clawsweeper re-review Current head c606f7e incorporates main once and passes all 947 focused tests. The broader-policy maintainer decision is recorded at #159221 (comment). The PR retains Related: #159184 for the remaining presentation concern; the body distinguishes original runtime/build proof from merged-head testing. |
|
🦞👀 Re-review progress:
|
|
Landed in e1238c2. HTTP 400 requests with only a transient inner code now skip same-model backoff while preserving genuine throttling and next-model fallback. The isolated Gateway reproduction fell from 10 requests/118.26s to one request/1.54s; 429, 503, Bedrock-shaped throttling and fallback controls passed. All 947 focused tests passed again after merging main, followed by green exact-head CI and hosted review. Thanks @NovaUnboundAi for the detailed report. #159184 remains open for the separate prompt-size error-copy concern. |
…nclaw#159221) Related: openclaw#159184 ## What Problem This Solves Fixes repeated same-model requests when an HTTP 400 rejection carries a generic transient inner code such as `rate_limit_exceeded`. ## User Impact A rejected request now returns promptly or advances to a configured fallback instead of waiting through nine identical failures. Genuine throttling and server errors still retry. This deliberately preserves existing rate-limit presentation, logging, cooldown and fallback reasons; it does not change the generic rate-limit error copy to prompt-size guidance. No settings, defaults, protocol or storage changes. ## Why This Change Was Made The classifier records that a non-transient 4xx is not eligible for same-model retry when only its generic inner code makes it transient. The existing recovery gate consumes that fact for assistant failures and thrown provider exceptions, including coerced failover errors. HTTP 408/409/410/429/499 retain their previous policy. Independent transient message/detail evidence, Bedrock's structured `ThrottlingException`, and prepared provider-hook decisions remain eligible. A blanket `400 => format` change would break intentional behavior: openclaw#133772 preserved structured-code presentation, including `RESOURCE_EXHAUSTED` behind a generic HTTP 400 invalid-request wrapper, and the existing corpus covers real Bedrock-style HTTP 400 throttling. Both remain unchanged and green. JSON error prose is evaluated separately from its code so the code cannot count as independent evidence for retrying itself. [Ayaan accepted this broader retry policy](openclaw#159221 (comment)), including immediate fallback/failure for a genuine throttle that supplies only a generic transient code behind a non-transient 4xx. ## Evidence Real isolated Gateway turns, using fresh builds and a local scripted OpenAI-compatible HTTP provider; no paid provider calls. Baseline: `3d129a06`; measured fix: `e02adc94`. | Response | Baseline requests | Fixed requests | Observed result | | --- | ---: | ---: | --- | | HTTP 400 + `rate_limit_exceeded` + reported prompt-size prose | 10 | 1 | CLI completes in 1.54 s instead of 118.26 s; no same-model backoff | | HTTP 400 + same code + generic `Request rejected` | — | 1 | Error surfaces in 1.33 s | | HTTP 400 without an inner code | 1 | 1 | Same schema-rejection result | | HTTP 429, twice, then success | 3 | 3 | Recovers successfully | | HTTP 503, twice, then success | 3 | 3 | Recovers successfully | | HTTP 400 `ThrottlingException`, twice, then success | 3 | 3 | Recovers successfully | Baseline failing-request offsets were 0, 1053, 2220, 4972, 11518, 21524, 51629, 66995, 85563 and 115957 ms. The fixed fallback runs each made one rejected request followed by one successful next-model request, both with and without the inner code. The Bedrock control uses its response shape through the local compatible transport, not a live AWS call. - The three classifier rejection cases fail on baseline and pass with the fix. Recovery-boundary tests also failed for raw and coerced prompt exceptions before repair; both now advance to fallback without backoff. Independent detail prose remains retryable, while the SDK's flat JSON `{code,message}` cannot promote its code into prose. - 947 tests across seven classifier, classification corpus, structured presentation, error-normalization, attempt recovery and retry-controller suites passed in 26.66 s on `e02adc94`, then passed again in 42.19 s on `c606f7e9` after merging current main once. Existing openclaw#133772 copy and Bedrock corpus assertions were not changed. - Fresh baseline and `e02adc94` builds, core types, scoped type-aware Oxlint, Oxfmt and whitespace checks passed. The merged head is covered by the fresh focused tests and required CI; the earlier runtime/build measurements are not a rebuild of that later merge. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #159184
What Problem This Solves
Fixes repeated same-model requests when an HTTP 400 rejection carries a generic transient inner code such as
rate_limit_exceeded.User Impact
A rejected request now returns promptly or advances to a configured fallback instead of waiting through nine identical failures. Genuine throttling and server errors still retry.
This deliberately preserves existing rate-limit presentation, logging, cooldown and fallback reasons; it does not change the generic rate-limit error copy to prompt-size guidance. No settings, defaults, protocol or storage changes.
Why This Change Was Made
The classifier records that a non-transient 4xx is not eligible for same-model retry when only its generic inner code makes it transient. The existing recovery gate consumes that fact for assistant failures and thrown provider exceptions, including coerced failover errors. HTTP 408/409/410/429/499 retain their previous policy. Independent transient message/detail evidence, Bedrock's structured
ThrottlingException, and prepared provider-hook decisions remain eligible.A blanket
400 => formatchange would break intentional behavior: #133772 preserved structured-code presentation, includingRESOURCE_EXHAUSTEDbehind a generic HTTP 400 invalid-request wrapper, and the existing corpus covers real Bedrock-style HTTP 400 throttling. Both remain unchanged and green. JSON error prose is evaluated separately from its code so the code cannot count as independent evidence for retrying itself.Ayaan accepted this broader retry policy, including immediate fallback/failure for a genuine throttle that supplies only a generic transient code behind a non-transient 4xx.
Evidence
Real isolated Gateway turns, using fresh builds and a local scripted OpenAI-compatible HTTP provider; no paid provider calls. Baseline:
4b225bae; measured fix:e02adc94.rate_limit_exceeded+ reported prompt-size proseRequest rejectedThrottlingException, twice, then successBaseline failing-request offsets were 0, 1053, 2220, 4972, 11518, 21524, 51629, 66995, 85563 and 115957 ms. The fixed fallback runs each made one rejected request followed by one successful next-model request, both with and without the inner code. The Bedrock control uses its response shape through the local compatible transport, not a live AWS call.
{code,message}cannot promote its code into prose.e02adc94, then passed again in 42.19 s onc606f7e9after merging current main once. Existing chore(deps): refresh eligible seven-day npm dependencies #133772 copy and Bedrock corpus assertions were not changed.e02adc94builds, core types, scoped type-aware Oxlint, Oxfmt and whitespace checks passed. The merged head is covered by the fresh focused tests and required CI; the earlier runtime/build measurements are not a rebuild of that later merge.