Skip to content

fix(codex): recover failed conversations while sibling work continues - #172287

Merged
steipete merged 5 commits into
openclaw:mainfrom
zhuyankarl:fix/codex-failed-thread-unload
Oct 15, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
zhuyankarl:fix/codex-failed-thread-unload

Conversation

@zhuyankarl

@zhuyankarl zhuyankarl commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #172279. Follow-up to #149000.

What Problem This Solves

Fixes repeated Codex conversation recovery failures after a provider error when another thread keeps the shared app-server active.

User Impact

A failed conversation can resume its original thread and history with refreshed instructions while sibling work continues. Healthy conversations also wait for asynchronous teardown before resuming. User-owned Codex homes and external proxy/socket connections retain their native retention settings. Provider rate limits still apply.

Why This Change Was Made

OpenClaw already owns warm subscription retention and child-work protection. Managed local agent-home app-servers now launch with thread_unload_delay_secs=0. The lifecycle owner waits for the matching notLoaded notification for up to two seconds, aborting with the run. Missing confirmation preserves the binding; the existing guarded whole-client replacement remains available for settled failures only when no sibling work would be interrupted.

Original fix by @zhuyankarl; maintainer cleanup coordinates healthy-thread teardown, preserves external connection behavior, replaces the expensive new native test with focused lifecycle cases, and updates the existing Gateway recovery controls.

Evidence

PR CI is the test and typecheck gate per maintainer policy. Live proof, local tests, local typechecks, and production-revert negative controls were intentionally skipped. No local Gateway or remote lease was started. The first exact-head run 38683475836 exposed fixture typing, stale managed-unload state, and replacement-clock failures. Those PR-caused failures are corrected in the follow-up commit; no inherited-failure exception is claimed. Final-head CI run 38684859899, attempt 2, head 76dca1a1833811b94c600216cd1176347523c256: 37 jobs passed, including production/test typechecks, lint, and the affected extension suites. Four affected test shards passed 663 tests across 36 files (122 binding/lifecycle, 134 auth/startup, 193 run-attempt, 214 extension tests).

CI infrastructure blocker: three jobs still failed in Set up job, before checkout or test execution, because GitHub could not download actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e (HTTP 404): changed tests, job 116260133227, Gateway, job 116260133434, and compact-large-13, job 116260133501. One diagnosed infrastructure retry used the workflow's supported GitHub-hosted fallback; these three downloads still failed. The aggregate gate remains red, so this PR is not yet land-ready. No inherited code-failure exception or maintainer acceptance is claimed.

  • Regression: preserves managed $nativeStatus history across $outcome with sibling=$sibling in the existing thread-lifecycle.binding.test.ts suite: failed/healthy unload, unrelated notification rejection, timeout with/without sibling protection, and abort. Uses the real RPC client/lifecycle with synthetic responses and fake timers.
  • Launch contract: owns unload retention only for managed local starts: $transport/$homeScope/proxy=$proxy in auth-bridge.test.ts, including explicit native retention settings and user-home/proxy/WebSocket/Unix exclusions.
  • Existing Gateway composition server.codex-failure-recovery.test.ts now expects same-thread/same-client recovery, changed instructions, preserved history, and sibling completion. Replacement/cancellation/unconfirmed-exit controls explicitly retain the native cache; no serial config or worker pin was added.
  • Removed the contributor's 299-line native test and lane registration. Its original reported cost was 3.435 seconds per case and 193.79 seconds cold wrapper time; those prior-head results are not current proof. The existing Gateway composition remains optional native validation. Final-head CI measured the six new regression cases at 112/87/102/103/89/145 ms (0.638 seconds combined), the five launch-scope cases at 0.049 seconds combined, and the replacement controls at 377/327 ms. The existing real Gateway cases passed for active-sibling recovery (21.005s), healthy reload (7.743s), idle Incognito (7.274s), and idle persistent siblings (6.421s). Those four native Gateway results are from the prior head; the final-head Gateway job never started because of the action download failure above. Dedicated live proof and a production-revert negative control were not run.
  • Changed-file oxfmt and static oxlint passed. Lint ran from clean trusted main using its rules with only the nonmatching ui/**/*.tsx Solid-plugin override omitted because that unrelated dependency is absent. No install was run. git diff --check passed.
  • Deslop removed redundant synchronous rechecks and obsolete native-test setup. Isolated Codex autoreview at P2: scoped-clean, no accepted/actionable findings; the final test-only CI repair received a separate scoped-clean review. The required main merge was conflict-free and changed none of the reviewed owner/test files or supplied source context.

Native dependency contract

Personally inspected the sibling Codex source at rust-v0.160.0, commit a956835d020762cb2b570053af06f643a11c0ecc, matching the plugin's @openai/codex 0.160.0 pin:

Review decisions and scope

ClawSweeper's healthy teardown P1 and outdated Gateway controls P2 are addressed above. Its additional live-proof asks are intentionally deferred: PR CI is the proof per maintainer policy. The managed-server retention policy is the requested fix scope; it adds no OpenClaw option and excludes user-home/external ownership. No separate approval is claimed.

The wait captures the exact physical client, thread ID, binding lease, and initial native status. Current host/run/client authority is checked after the wait and before native writes; the binding remains serialized by its existing owner. Replacement eligibility reads current leases, pending acquisitions, sibling claims, and routes after waiting. Configuration is built after the wait or remains bound to the current turn's existing preparation authority. There is no detached recovery task, new path, or new retention store.

Production is net +57 lines versus main: the bounded notification/abort handoff and shared launch-scope rule need these additions; no unrelated deletion is used to meet the campaign LOC target. Final numstat: production +60/−3 (net +57), tests +239/−85 (net +154), docs +10/−0 (net +10); total +309/−88 (net +221) across 13 files. Compared with the contributor patch, maintainer cleanup removes 142 lines overall.

@clawsweeper

clawsweeper Bot commented Oct 14, 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.

@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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 14, 2026
@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR waits for managed Codex threads to unload before resuming their history with refreshed instructions while sibling work continues.

Example: Conversation A fails with HTTP 400 while conversation B remains active, then A receives NEW_POLICY_BETA.

  • Before: A repeatedly refuses configuration reload because replacing the shared client would interrupt B.
  • After: A waits for its own unload notification and resumes the same thread with its history and new instructions while B continues.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch resolves the earlier defects and has passing exact-head CI, but this external PR has not supplied the required real-behavior evidence; persisted formats and schemas are unchanged.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A failed Codex conversation cannot continue with changed instructions while another conversation keeps its shared app-server active.
Reason: The source establishes a real remaining defect, and the area owner's cleanup adopts a focused repair while preserving external ownership and sibling protections.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a concrete recovery failure still present on main, and both previous findings are resolved; exact-head CI now passes.

Priority: P1
Reviewed head: 76dca1a1833811b94c600216cd1176347523c256

Before merge

  • Add real behavior proof - The supplied evidence consists of lifecycle tests, native Gateway test results, and CI; dedicated live proof was explicitly skipped. Attach redacted terminal output or logs from a shipped Gateway showing a settled failure, changed instructions, preserved history, same-client recovery, and sibling completion, plus fresh-install and latest-stable upgrade behavior with existing settings and history intact; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Supply the shipped recovery and fresh-install/latest-stable upgrade captures described below; a regression failing on the base and passing on the head has not been demonstrated.
Agent review details

How this fits together

Gateway chat sends enter the Codex plugin's thread lifecycle owner, which coordinates subscriptions, native configuration, and persisted bindings before admitting the next native turn.

flowchart TD
  A[Gateway chat send] --> B[Codex lifecycle owner]
  B --> C[Release retained subscription]
  C --> D[Confirm exact thread unload]
  D --> E[Resume original thread]
  E --> F[Apply current policy and start turn]
  B --> G[Preserve active sibling ownership]
Loading

Technical review

Best possible solution:

Recover through the existing per-thread lifecycle owner, preserving native history and active siblings while retaining guarded whole-client replacement as fallback.

Do we have a high-confidence way to reproduce the issue?

Current-main sibling vetoes, the existing Gateway refusal scenario, and the personally inspected pinned Codex reload contract establish the failure path; no target code was executed during this review.

Is this the best way to solve the issue?

The revised implementation fixes the owning lifecycle boundary with an exact-thread unload receipt, bounded cancellation-aware waiting, and existing authority checks rather than interrupting the shared process.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 520302d8ee63.

Provenance checked

  • Settled-failure recovery changes intended behavior with a stated reason (6d410b5: Recover on a fresh client only after confirmed physical exit, with active and Incognito siblings vetoing replacement.)
  • Configuration teardown observation keeps the original intent (f5f44fa: Native resume can acknowledge ignored overrides, so exact-thread unload confirmation must precede acceptance of changed configuration.)
  • Native launch override handling changes intended behavior with a stated reason (c85129f: Preserve native override bytes and precedence through one argument-normalization owner while enforcing OpenClaw-owned launch settings.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f5f44fa adds extensions/codex/src/app-server/thread-lifecycle-adoption.ts:268 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f5f44faeca4e; files: extensions/codex/src/app-server/thread-lifecycle-adoption.ts)
  • Mert Başar: Raw commit 6d410b5 adds extensions/codex/src/app-server/thread-lifecycle-io.ts:121 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6d410b5f9226; files: extensions/codex/src/app-server/thread-lifecycle-io.ts)
  • Ayaan Zaidi: Raw commit 64c543a adds extensions/codex/src/app-server/thread-lifecycle-adoption.ts:311 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 64c543a78b7f; files: extensions/codex/src/app-server/thread-lifecycle-adoption.ts)

PR surface

Source +57, Tests +154, Docs +10. Total +221 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 60 3 +57
Tests 7 239 85 +154
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 309 88 +221

Review metrics

Metric Value Why it matters
Native retention policy Managed default: 60 seconds → 0; no new OpenClaw option The owner-directed launch override changes effective native retention only for local agent-home servers; user-home and external transports are excluded.

Root-cause cluster

Relationship: same_root_cause
Canonical: #172279
Summary: This PR implements the canonical active-sibling recovery report; the merged predecessor handled only eligible whole-client replacement.

Members:

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

Labels

Label changes:

  • remove merge-risk: 🚨 session-state: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.

Label justifications:

  • P1: A settled provider failure can repeatedly block an existing conversation while unrelated sibling work continues.
  • merge-risk: 🚨 compatibility: The launch override takes precedence over configured native retention for managed local agent-home servers; the area owner's cleanup explicitly retains this scoped tradeoff.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach the redacted recovery and upgrade captures specified in the proof assessment.

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 execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-14T16:12:30.325Z sha 2016abd :: needs real behavior proof before merge. :: [P1] Await teardown for healthy threads before resuming | [P2] Update the Gateway recovery controls for per-thread unloading

Reviewed October 15, 2026, 2:14 AM ET / 06:14 UTC (Revision 2).

steipete and others added 2 commits October 14, 2026 21:48
Wait for healthy and failed managed threads to unload before refreshing
configuration, preserving the binding when teardown cannot be confirmed.
Keep external/user-home retention and guarded shared-client replacement.
Replace the added native test with focused lifecycle regressions and update
Gateway recovery controls for same-client recovery and sibling survival.

Fixes openclaw#172279. Original fix by @zhuyankarl in openclaw#172287.
Proof: changed-file lint/format and isolated P2 autoreview; PR CI owns tests
and typechecks per maintainer policy. Live proof intentionally skipped.

Co-authored-by: zhuyankarl <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Oct 15, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Oct 15, 2026
@steipete
steipete merged commit 73c9e39 into openclaw:main Oct 15, 2026
268 of 286 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

steipete added a commit that referenced this pull request Oct 15, 2026
73c9e39 (#172287) requires confirmed unloading before managed
thread resume. Report an unloaded thread in the startup fixture so the
exact overload error and binding/shared-client preservation checks run.

14eee34 (#171218) disables native shell features alongside code mode.
Include both flags in the complete bounded-media request expectations.

Repair latent red-main failures exposed by PR #172381, CI run 38696213621.
Static oxlint, oxfmt, whitespace checks, and isolated P0-P2 review pass.
Test and typed-lint proof use PR CI because local preparation timed out.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…openclaw#172287)

* fix(codex): recover failed conversations while sibling work continues

* fix(codex): coordinate managed thread teardown before recovery

Wait for healthy and failed managed threads to unload before refreshing
configuration, preserving the binding when teardown cannot be confirmed.
Keep external/user-home retention and guarded shared-client replacement.
Replace the added native test with focused lifecycle regressions and update
Gateway recovery controls for same-client recovery and sibling survival.

Fixes openclaw#172279. Original fix by @zhuyankarl in openclaw#172287.
Proof: changed-file lint/format and isolated P2 autoreview; PR CI owns tests
and typechecks per maintainer policy. Live proof intentionally skipped.

Co-authored-by: zhuyankarl <[email protected]>

* test(codex): update managed recovery fixtures and clocks

---------

Co-authored-by: zhuyankarl <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…172947)

96ccbf0 (openclaw#172287) requires confirmed unloading before managed
thread resume. Report an unloaded thread in the startup fixture so the
exact overload error and binding/shared-client preservation checks run.

323baf4 (openclaw#171218) disables native shell features alongside code mode.
Include both flags in the complete bounded-media request expectations.

Repair latent red-main failures exposed by PR openclaw#172381, CI run 38696213621.
Static oxlint, oxfmt, whitespace checks, and isolated P0-P2 review pass.
Test and typed-lint proof use PR CI because local preparation timed out.
RomneyDa added a commit that referenced this pull request Oct 30, 2026
…#172287)

* fix(codex): recover failed conversations while sibling work continues

* fix(codex): coordinate managed thread teardown before recovery

Wait for healthy and failed managed threads to unload before refreshing
configuration, preserving the binding when teardown cannot be confirmed.
Keep external/user-home retention and guarded shared-client replacement.
Replace the added native test with focused lifecycle regressions and update
Gateway recovery controls for same-client recovery and sibling survival.

Fixes #172279. Original fix by @zhuyankarl in #172287.
Proof: changed-file lint/format and isolated P2 autoreview; PR CI owns tests
and typechecks per maintainer policy. Live proof intentionally skipped.

Co-authored-by: zhuyankarl <[email protected]>

* test(codex): update managed recovery fixtures and clocks

---------

Co-authored-by: zhuyankarl <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 73c9e39)
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex failed-thread recovery remains blocked while a sibling thread is active

2 participants