Skip to content

fix(codex): keep the current task after overload retries - #166868

Merged
steipete merged 2 commits into
mainfrom
fix/retry-continuation-carrier
Oct 8, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/retry-continuation-carrier

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

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.

Fault Baseline production Fixed production
Before work Retry omitted Task B; final reply answered Task A Retry retained Task B; final reply answered Task B
After a real file read Retry omitted Task B and the read receipt; final reply answered Task A Retry retained Task B and the receipt; answered Task B with exactly one read

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 (main 109bd47910990e8a2e12b8f1532e1bbbccf738e5): preserved both main’s compaction/cancellation tests and the carrier regression. All four changed test files passed (112 tests, 116.88 s), together with tsgo:core, core-test-agents-other, tsgo:extensions, and tsgo: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 b9f71681289994c55721a2e5f25e9c22eacfa139 validation: 68 module test files / 693 tests passed on the fresh AWS lease (1,082.65 s), plus tsgo:core, the core-test-agents-other test shard, tsgo:extensions, and tsgo: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 (digest aa235188), 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.ts

The task-owned fixture uses createQaGatewayChild, isolated state and an ephemeral port, mock-openai, configured Codex runtime, codexDynamicToolsLoading: "direct", and the existing read/web_search allowlist. It emits SSE response.failed with server_is_overloaded, then records retry input and the final chat.history reply. 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.

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]>
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: codex size: M labels Oct 8, 2026
@steipete
steipete marked this pull request as ready for review October 8, 2026 01:34
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 10:19 PM ET / October 8, 2026, 02:19 UTC (Revision 2).

ClawSweeper review

What this changes

The 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.

  • Before: The rebuilt retry omits Task B and the read receipt, then answers Task A.
  • After: The retry retains Task B and the receipt, answers Task B, and performs exactly one read.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, owner-supported repair with production-boundary before/after proof, meaningful negative controls, and no actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied before/after results exercise shared recovery through an isolated production Gateway and real native Codex transport with injected overloads before work and after a real read; fixed retries retain Task B and completed evidence with one read. The merge refresh preserves the tested retry implementation, with additional exact-head regression results. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After a temporary overload, Codex can answer an older task while leaving the user’s current request unanswered.
Reason: The change repairs an observed wrong-task response through the existing recovery owner. The area owner’s proposal explicitly accepts the optional harness extension and documents its compatibility behavior.

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
Reviewed head: 97b78087ce082f31789da22586f63356414408d5

Before merge

None.

Findings

None.

Agent review details

How this fits together

OpenClaw’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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point. Added test files: 4.

Security

None.

Evidence

What I checked:

  • Pinned introduced delta: Reviewed the merge-base-to-head delta rather than treating current-main drift or the stale test merge as PR edits. (97b78087ce08)
  • Current-main necessity and base compatibility: None of the introduced paths changed between the pinned base and fetched main. Main retains transcript-only continuation without this branch’s request-and-snapshot carrier. (src/agents/embedded-agent-runner/run/session-prompt-state.ts:279, 3ac5189b9446)
  • Production recovery owner: Transient recovery supplies the attempt snapshot; session prompt state retains the original request and accumulates snapshots while preserving the raw-model guard and model-only continuation instruction. (src/agents/embedded-agent-runner/run/session-prompt-state.ts:284, 97b78087ce08)
  • Bounded, non-authorizing Codex consumption: Codex appends retained work through its existing bounded projection, preserves tool results with existing redaction, and keeps live host and connection assertions. The carrier does not mint execution authority or persist a new user turn. (extensions/codex/src/app-server/run-attempt-prompt.ts:168, 97b78087ce08)
  • Production fault-injection proof: The supplied PR body, captured at source revision a631455156e36c8b57ced64f083f23e146508311bd5719b473d42b34243ae5a9, records fresh AWS runs through an isolated Gateway and real native Codex client against a loopback provider. Before-work and after-read overloads fail on baseline and retain Task B after the fix; the after-read case records exactly one read. This proves transport and recovery behavior, not real-model semantics. (b9f716812899)
  • Regression coverage and merge refresh: The new Codex suite uses an actual SQLite admission receipt and verifies that fenced history excludes Task B before checking native turn input. The body reports four production-reverted negative controls and the overload-to-refresh negative control, followed by 112 passing tests and affected type checks on the refreshed head. Tests were inspected, not executed during this review. (extensions/codex/src/app-server/run-attempt.retry-continuation.test.ts:30, 97b78087ce08)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • changeroa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

PR surface

Source +46, Tests +232, Docs +16. Total +294 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 7 69 23 +46
Tests 5 232 0 +232
Docs 1 16 0 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 317 23 +294

Review metrics

Metric Value Why it matters
Harness contract extension 1 optional parameter; 0 new configuration options The documented carrier repairs fenced retries while keeping harnesses that ignore it source-compatible.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #165463
Summary: This PR is the proven candidate repair for the reported fenced-history retry defect and builds on the earlier request-preservation proposal.

Members:

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

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: Observed overload retries can deliver a successful-looking answer to a previous task instead of the current request.
  • merge-risk: 🚨 compatibility: The harness API gains an optional context carrier; the accepted design documents legacy behavior and retains the raw-model exception.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-08T01:41:19.889Z sha b9f7168 :: needs maintainer review before merge. :: none

…n-carrier

# Conflicts:
#	src/agents/embedded-agent-runner/run.session-prompt-state.test.ts
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 8, 2026
@steipete
steipete merged commit be4c0b1 into main Oct 8, 2026
142 checks passed
@steipete
steipete deleted the fix/retry-continuation-carrier branch October 8, 2026 02:29
@steipete

steipete commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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.

[Bug]: Overload same-model retry omits latest user request and answers a previous task in a dashboard session

1 participant