Repository navigation
fix(codex): keep the current task after overload retries - #166868
Conversation
Carry the current request and settled attempt snapshots through the optional harness continuation contract. Codex projects completed work alongside its admission-fenced history; later plugin refreshes retain the same facts. Builds on #165593 by @Baumus. Regression and fresh-machine Gateway fault injection cover overloads before work and after a completed read. Fixes #165463 Co-authored-by: Baumus <[email protected]>
|
🦞👀 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 October 7, 2026, 10:19 PM ET / October 8, 2026, 02:19 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch carries the current request and completed work into Codex retries and preserves that work through a later plugin refresh. Example: Submit Task B after Task A completes and encounter an overload after a file read.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful: current main still lacks the retry context carrier, the supplied production proof exercises the defect, and no blocking patch finding remains. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherOpenClaw’s agent runner coordinates retries and passes prepared work to the Codex plugin, which builds input for the native Codex app-server. The changed path restores current-turn context that the historical transcript intentionally excludes. flowchart TD
A[Current user request] --> B[Agent runner]
B --> C[Codex native attempt]
C --> D{Transient overload}
D --> E[Retained request and completed work]
F[Admission-fenced history] --> G[Bounded Codex input projection]
E --> G
G --> C
C --> H[Answer to current task]
Technical reviewBest possible solution: Keep current-turn recovery context with the shared runner and let Codex consume it through the existing bounded projection without replaying completed actions. Do we have a high-confidence way to reproduce the issue? Yes: the admission-fenced read excludes the current turn while baseline recovery substitutes a generic prompt, and the supplied Gateway/native-Codex fault injection demonstrates the resulting Task A answer. This read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes: the shared runner retains current-turn facts and the existing Codex projection consumes them, preserving the admission fence, legacy harness behavior, and completed-action handling. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3ac5189b9446. Provenance checked
TestingProof path: shipped entry point. Added test files: 4. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +46, Tests +232, Docs +16. Total +294 across 13 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. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
|
…n-carrier # Conflicts: # src/agents/embedded-agent-runner/run.session-prompt-state.test.ts
|
Merged via squash.
|
…6868) Carry the current request and settled attempt snapshots through the optional harness continuation contract. Codex projects completed work alongside its admission-fenced history; later plugin refreshes retain the same facts. Builds on openclaw#165593 by @Baumus. Regression and fresh-machine Gateway fault injection cover overloads before work and after a completed read. Fixes openclaw#165463 Co-authored-by: Baumus <[email protected]>
What Problem This Solves
Fixes replies to a previous task after a transient same-model overload in a Codex conversation, including overloads after completed tool work.
User Impact
Codex retries retain the current request and completed tool results, so they can continue the active task without repeating completed actions. No configuration or data migration is required. The new harness field is optional; harnesses that ignore it retain their existing behavior.
Why This Change Was Made
The admission fence correctly excludes the current logical turn from historical context. Recovery was replacing its request with a continuation instruction without carrying the excluded work. The host now supplies the original request and settled attempt snapshots through an optional continuation carrier; Codex consumes them through its existing bounded projection. The host also preserves these facts across a subsequent plugin refresh.
Builds on #165593 by @Baumus.
Fixes #165463
Evidence
Fresh AWS Crabbox proof used a real isolated Gateway and native Codex app-server with a synthetic loopback provider. Each case completed unrelated Task A, submitted Task B, and injected one native overload. An existing narrow tool policy exercised native-thread reconstruction; ordinary warm native history can mask the defect.
The provider made deterministic decisions from the complete input it received. This proves live Gateway/Codex recovery and tool transport with injected faults; it is not a real-model semantic evaluation. Both Gateway processes stopped cleanly.
Unit negative controls reverted only production code: all four real admission-fence Codex cases failed on the missing current request, and the overload→plugin-refresh regression failed on missing completed-work facts. Restoring the fix passed both boundaries. Existing prompt-state tests retain legacy and raw-model behavior.
Merge refresh
97b78087ce082f31789da22586f63356414408d5(main109bd47910990e8a2e12b8f1532e1bbbccf738e5): preserved both main’s compaction/cancellation tests and the carrier regression. All four changed test files passed (112 tests, 116.88 s), together withtsgo:core,core-test-agents-other,tsgo:extensions, andtsgo:extensions:test. The production-reverted negative control failed all four Codex cases for the expected missing-request reason; exact production bytes were restored. No retry production hunks changed during resolution, so the existing live proof is reused. Exact-head CI is attached and running.Original candidate
b9f71681289994c55721a2e5f25e9c22eacfa139validation: 68 module test files / 693 tests passed on the fresh AWS lease (1,082.65 s), plustsgo:core, thecore-test-agents-othertest shard,tsgo:extensions, andtsgo:extensions:test. Focused lint, formatting, SDK export and surface checks passed. The SDK API diff reports only the approved optional field through 131 reachable export references (digestaa235188), with no entrypoint/export additions or removals. Independent branch autoreview is clean through P2.The full changed-file check encountered one inherited failure: the dead-export scan flags
scripts/publish-model-catalog.mts:readRecommendedModels. That file is byte-identical to the starting baseline; all preceding checks and the remaining individual guards passed. This PR does not modify that unrelated owner.Production is +69/−23 lines (net +46); tests and test routing +232/−0; docs +16/−0. The production growth is the optional contract, host retention/handoff, and bounded Codex consumption; no unrelated deletions fund it.
Proof commands and test cost
Task-owned synthetic fixture SHA-256:
02413227fdf6f4228727eb946d9ff31e7c60a437953da20ee8f95d517d401d3f.OPENCLAW_BUILD_PRIVATE_QA=1 node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime node --import ./scripts/tsx.mjs .artifacts/continuation-live-proof.ts --expect-baseline # Restore the candidate production patch and rebuild qaRuntime. node --import ./scripts/tsx.mjs .artifacts/continuation-live-proof.tsThe task-owned fixture uses
createQaGatewayChild, isolated state and an ephemeral port,mock-openai, configured Codex runtime,codexDynamicToolsLoading: "direct", and the existingread/web_searchallowlist. It emits SSEresponse.failedwithserver_is_overloaded, then records retry input and the finalchat.historyreply. The after-work fault is injected only after the actual read returns its synthetic receipt. The script is proof tooling, not a committed test dependency.The live baseline and fixed fixture phases took 36.25 s and 34.98 s, excluding builds. Local focused proof: prompt-state 13 tests, recovery 80 tests; new Codex test 4 cases plus 4 bounded-continuity siblings; refresh integration 13 tests. The new Codex cases took 5.67 s test time (94.66 s cold paired invocation); the new refresh case took 0.67 s (112.42 s cold full-file invocation). Runs used
node scripts/run-vitest.mjs <explicit files> --maxWorkers=1. Hosted CI cost is pending its first run.