Repository navigation
fix: continue agent tasks after temporary rate limits - #139397
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: blocked before merge. Reviewed September 5, 2026, 6:46 PM ET / 22:46 UTC. ClawSweeper reviewWhat this changesThe PR continues interrupted agent tasks from their existing transcript with bounded retries, preserves final-answer ownership, and displays retry progress through chat reconnects. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix against current main, with no concrete introduced correctness defect found. The earlier generic migration blocker is not supported by the inspected storage and reader boundaries. Priority: P2 Review scores
Verification
How this fits togetherThe agent runner turns provider failures into recovery, fallback, or final errors. Codex supplies native turn results, while the Gateway and chat UI preserve transcript content and display run progress. flowchart TD
A[Provider failure] --> B[Recovery eligibility]
B --> C[Bounded cancellable wait]
C --> D[Continue existing transcript]
D --> E[Final answer]
B --> F[Fallback or terminal error]
C --> G[Gateway and chat retry status]
D --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource -10, Tests +311, Docs +11. Total +312 across 44 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: 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: Keep one bounded continuation owner that preserves completed work, existing retry preferences, cancellation, and terminal-error handling. Do we have a high-confidence way to reproduce the issue? Yes: current-main source excludes a terminal 429 after completed tools from transcript continuation, matching the supplied baseline reproduction; this read-only review did not execute it. Is this the best way to solve the issue? Yes: consolidating recovery before existing failure escalation avoids competing retry loops, while preserving transcript identity and existing saved settings. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a0ea2b71e335. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
6a9fcf5 to
480187c
Compare
7c297ce to
19dd553
Compare
Resume the existing transcript with bounded backoff after transient provider failures, preserving completed work and keeping retries visible. Consolidate retry decisions and reserve final transcript ownership for the eventual answer. Verified with native Codex, browser recovery and cancellation, and live OpenAI fault injection. Closes #139312.
f55517c to
3f2153a
Compare
|
Merged via squash.
|
* fix: continue agent tasks after temporary rate limits Resume the existing transcript with bounded backoff after transient provider failures, preserving completed work and keeping retries visible. Consolidate retry decisions and reserve final transcript ownership for the eventual answer. Verified with native Codex, browser recovery and cancellation, and live OpenAI fault injection. Closes openclaw#139312. * test: align recovery fixtures with bounded continuation * refactor(codex): keep retry status in event projection * test: initialize the readonly retry counter in failover fixture
Closes #160534 ## What Problem This Solves Fixes repeated provider requests when an HTTP 400 response has an empty body, wasting rate limits and potentially hiding the original error behind subsequent throttling. ## User Impact A deterministic bodyless client error now surfaces after one model request rather than four. Transient recovery, empty successful response repair, and normal replies retain their existing behavior. No configuration changes are required. ## Why This Change Was Made The silent-error recovery path previously treated an unclassified bodyless HTTP 400 like a missing model response. It now checks the existing HTTP-status and transient-retry evidence owners before replaying a client error, without introducing another retryable-status list or reclassifying the failure as a format error. The transport's existing retryable HTTP-status predicate is shared with the silent-error guard, preserving bodyless 409 conflict recovery without changing the transport's SDK wait cap or the transient retry budget. The reasoning-only, replay-safe recovery introduced in #92191 remains intact, as does the separate transient recovery budget from #134281 and #139397. Thanks to @bogdandragosvasile for the exact local reproduction. No overlap with Pash/Sarah changes. ## Evidence Ran `pnpm openclaw --profile <isolated-profile> agent exec` against the issue's local empty-body fault server, using task-owned config, state, home, workspace, and ports. Baseline: `25d771cb8203f5afeea7b7c9dc8060210db8e43d`. | Provider response | Baseline model requests | Fixed model requests | Observed result | | --- | ---: | ---: | --- | | Empty HTTP 400 | 4 | 1 | Original `400 status code (no body)` surfaces | | Empty HTTP 409 | 4 | 4 | Existing silent-error retries, then original conflict error | | Empty HTTP 429 | 10 | 10 | Existing transient retries, then rate-limit error | | Empty HTTP 200 | 2 | 2 | Existing visible-answer retry, then incomplete-response error | | Normal streamed HTTP 200 | 1 | 1 | `pong` | Counts are `POST /v1/chat/completions` requests; unrelated `GET /` probes are excluded. Baseline controls were run with the production change reverted in the same worktree. The new bodyless 400/422 owner regressions both failed before the fix (`retry` instead of `proceed`) and pass afterward. The focused run of `run.owner-policy.test.ts`, `failover/classify.test.ts`, and `provider-transport-fetch.test.ts` with `pnpm test ... --maxWorkers=1` passed all 133 tests in 40.6 seconds total wall time including worker compilation. This includes the new 409 preservation case, existing reasoning-only and replay-unsafe-tool cases, and existing SDK retry-cap tests. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes openclaw#160534 ## What Problem This Solves Fixes repeated provider requests when an HTTP 400 response has an empty body, wasting rate limits and potentially hiding the original error behind subsequent throttling. ## User Impact A deterministic bodyless client error now surfaces after one model request rather than four. Transient recovery, empty successful response repair, and normal replies retain their existing behavior. No configuration changes are required. ## Why This Change Was Made The silent-error recovery path previously treated an unclassified bodyless HTTP 400 like a missing model response. It now checks the existing HTTP-status and transient-retry evidence owners before replaying a client error, without introducing another retryable-status list or reclassifying the failure as a format error. The transport's existing retryable HTTP-status predicate is shared with the silent-error guard, preserving bodyless 409 conflict recovery without changing the transport's SDK wait cap or the transient retry budget. The reasoning-only, replay-safe recovery introduced in openclaw#92191 remains intact, as does the separate transient recovery budget from openclaw#134281 and openclaw#139397. Thanks to @bogdandragosvasile for the exact local reproduction. No overlap with Pash/Sarah changes. ## Evidence Ran `pnpm openclaw --profile <isolated-profile> agent exec` against the issue's local empty-body fault server, using task-owned config, state, home, workspace, and ports. Baseline: `f6f301f702dfed02b63423237db57f96e8f4145a`. | Provider response | Baseline model requests | Fixed model requests | Observed result | | --- | ---: | ---: | --- | | Empty HTTP 400 | 4 | 1 | Original `400 status code (no body)` surfaces | | Empty HTTP 409 | 4 | 4 | Existing silent-error retries, then original conflict error | | Empty HTTP 429 | 10 | 10 | Existing transient retries, then rate-limit error | | Empty HTTP 200 | 2 | 2 | Existing visible-answer retry, then incomplete-response error | | Normal streamed HTTP 200 | 1 | 1 | `pong` | Counts are `POST /v1/chat/completions` requests; unrelated `GET /` probes are excluded. Baseline controls were run with the production change reverted in the same worktree. The new bodyless 400/422 owner regressions both failed before the fix (`retry` instead of `proceed`) and pass afterward. The focused run of `run.owner-policy.test.ts`, `failover/classify.test.ts`, and `provider-transport-fetch.test.ts` with `pnpm test ... --maxWorkers=1` passed all 133 tests in 40.6 seconds total wall time including worker compilation. This includes the new 409 preservation case, existing reasoning-only and replay-unsafe-tool cases, and existing SDK retry-cap tests. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #139312
What Problem This Solves
Temporary RPM/TPM limits could stop an agent after it had completed tools or written part of an answer, leaving the operator to restart useful work manually.
Why This Change Was Made
The shared attempt recovery owner waits with jittered exponential backoff, then injects a short continuation instruction against the existing transcript. The agent preserves completed work and inspects uncertain actions before deciding what to retry. The original user request is not appended again.
The default changes from three to up to eight continuations within the existing 90-second window, honoring pacing carried by provider errors. Prompt and assistant failure handlers retain profile/auth/fallback responsibilities; duplicate transient decisions and the special transport-drop counter are removed. Native Codex transport retries remain native, and terminal failures enter the shared continuation flow.
Failed deferred Codex attempts retain partial text and diagnostics without claiming final-message ownership. The eventual answer retains that ownership and any settlement warning. Retry progress uses the existing working indicator, survives reconnects, and clears on newer activity.
User Impact
Brief provider failures recover automatically. Stop cancels the wait. Authentication failures, billing/long-quota exhaustion, refusals, and operation-specific terminal outcomes keep their existing handling; timeout-compaction recovery retains priority.
No new configuration option, database schema, or protocol version. The existing embedded-runtime
retry.provider.maxRetriessetting still overrides the default. Relative to the current merge base, production is −10 lines, tests are +311, and docs are +11. Already-landed cleanup is excluded.Evidence
Test fixtures now state their retry budgets where they test terminal suspension or auth bookkeeping. The retry defaults and cancellation behavior retain separate controller and live-flow coverage. Event formatting stays with the existing Codex event owner, keeping the combined modules within the file-size limit.
Compatibility: the preamble helper forwards an existing event sequence into an in-memory UI reducer; it changes no stored representation. Existing transcript identities, partial content, and diagnostics remain. Reload and delayed-snapshot tests cover final ownership and retry-status ordering.
Review follow-through: merge conflicts are resolved while preserving the newer recovery refactors and deleted adapter. The integrated head passed 182 recovery/session tests and the affected type checks. The attached screenshots and recording were visually inspected locally; the automated review environment could not retrieve them, so the existing verified assets are retained.
Direct upstream inspection: HTTP 429 classification, native retryability, and retry notifications.
The final CI rerun cleared intermittent failures in unchanged Chrome bootstrap, A2UI rendering, and test-process cleanup; no assertions were weakened.
The attached captures contain synthetic users/data. The HTTP/SSE fixture makes Codex's initial WebSocket-to-HTTPS fallback notice expected.
attachment-1309564108.mp4