Repository navigation
fix: recover queued Codex chats and preserve startup failures - #182104
Conversation
Co-authored-by: jjjhenriksen <[email protected]>
Co-authored-by: jjjhenriksen <[email protected]>
Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 14d44768-68ef-454c-9c08-e3fdf92d38de
|
🦞👀 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. What this changesThis PR recovers missed Codex thread closures and preserves claimed session-writer facts through queued startup failures and cancellations. Example: Chat A unloads before closure tracking attaches, while chat B keeps the retired Codex process alive.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses two concrete remaining failures using existing lifecycle owners, and no actionable patch defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherQueued replies enter the shared agent executor, which returns terminal outcomes for accounting and delivery; the Codex plugin separately coordinates native-thread handoff between physical app-server clients. flowchart TD
A[Queued chat] --> B[Shared agent executor]
B --> C[Codex thread lifecycle]
C --> D[Old client status and closure]
D --> E[Successor native resume]
E --> F[Native writer lock]
B --> G[Terminal accounting]
G --> H[Reply delivery]
Technical reviewBest possible solution: Preserve claimed writer facts through terminal outcomes and recover missed closure information within the existing exact-client handoff owner. Do we have a high-confidence way to reproduce the issue? Current-main source establishes both failure paths, and the supplied regressions report failures on the original implementation; this read-only review executed no target code. Is this the best way to solve the issue? The patch repairs the two existing owners directly, preserves current-writer and native persistence checks, and adds no competing state owner, retry loop, or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5a1187ca8112. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +30, Tests +483, Docs +3. Total +516 across 12 files. Added test files: 2. View PR surface stats
LabelsLabel changes: No label 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)
Reviewed October 24, 2026, 12:15 AM ET / 04:15 UTC (Revision 2). |
Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 36083a45-82ec-4a8f-9d39-2fd02c208a58
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…aw#182104) * Merge selected base main Co-authored-by: jjjhenriksen <[email protected]> * fix: preserve queued startup failures and cancellations Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 14d44768-68ef-454c-9c08-e3fdf92d38de * Publish openclaw/quiet-barnacle-2 Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 36083a45-82ec-4a8f-9d39-2fd02c208a58 * test(codex): remove redundant mocked handoff success case * fix(codex): keep retired-owner fence when passive thread read fails * test(codex): initialize old native process before its successor --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: jjjhenriksen <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
* Merge selected base main Co-authored-by: jjjhenriksen <[email protected]> * fix: preserve queued startup failures and cancellations Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 14d44768-68ef-454c-9c08-e3fdf92d38de * Publish openclaw/quiet-barnacle-2 Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 36083a45-82ec-4a8f-9d39-2fd02c208a58 * test(codex): remove redundant mocked handoff success case * fix(codex): keep retired-owner fence when passive thread read fails * test(codex): initialize old native process before its successor --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: jjjhenriksen <[email protected]> Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 1104add)
* Merge selected base main Co-authored-by: jjjhenriksen <[email protected]> * fix: preserve queued startup failures and cancellations Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 14d44768-68ef-454c-9c08-e3fdf92d38de * Publish openclaw/quiet-barnacle-2 Worked on by: - @jjjhenriksen Co-authored-by: jjjhenriksen <[email protected]> OpenClaw-Publication: 36083a45-82ec-4a8f-9d39-2fd02c208a58 * test(codex): remove redundant mocked handoff success case * fix(codex): keep retired-owner fence when passive thread read fails * test(codex): initialize old native process before its successor --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: jjjhenriksen <[email protected]> Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 1104add) Co-authored-by: jjjhenriksen <[email protected]> Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 94ef20a88dce9508d06cf74a5f35c7c6e77d5777)
What Problem This Solves
Fixes queued Codex chats staying at “Waiting for turn to start…” after a plugin reload, and startup failures or cancellations being replaced by terminal-accounting errors.
User Impact
A chat whose old thread already unloaded can resume without waiting for unrelated chats to release the retired Codex process. Startup errors retain their intended reply, and cancellation remains cancellation. Still-loaded threads, genuine session/writer replacements, and active ownership remain fenced; execution is not replayed. No configuration, schema, or migration changes are required.
Why This Change Was Made
Preserve the turn's already-claimed writer through rejected and aborted outcomes. For the separate Codex startup wait, recover a missed closure receipt with one metadata-only read from the exact old client: only a matching thread with
notLoadedstatus permits handoff. Native resume still enforces its exclusive persistence writer lock. Process exit, exact closure, and cancellation retain their existing ownership and cleanup paths.Incorporates @jjjhenriksen's follow-up #182161 at
2ebd4018179148e3b8fc8faf592050bc79d4af9d, with an additional real-native regression and updated runtime documentation.Thanks @jjjhenriksen for the report and reproduction direction.
Work sessions
Evidence
Terminal accounting session changedand pass with retained writer facts. Replacement-session/lifecycle/writer guards remain intact.startOrResumeThreadon a second real process and complete its next turn. A loaded sibling remains fenced and completes another turn on the old process while that handoff waits; cancelling only the wait leaves the old client alive. Exactly three loopback model requests complete, with no operator credentials or OpenAI service calls.git diff --checkpass. Independent Auto Review of the combined patch: scoped clean at its default P0 threshold.Native contract inspection and verification limits
Personally inspected the pinned Codex 0.162.1 source:
app-server/src/request_processors/thread_processor.rs(thread/read),thread_lifecycle.rs(shutdown and closure notification), andthread-store/src/local/live_writer.rs(resume's writer lock).This proves the native missed-closure startup mechanism in isolation, not deployment to the affected live Gateway, the complete six-minute incident, or remote OpenAI service behavior. The prior standalone root test command's worker-compilation interruption remains non-verdict evidence; successful runs use the supported repository Vitest entrypoint. An initial package-boundary typecheck selected without its build prerequisites failed setup; the canonical extension/type-aware gates above passed. Documentation link audit reported 15,867 checked links and zero broken links, but its runner aborted after that summary, so a clean audit exit is not claimed.
Worked on by