Repository navigation
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR waits for background-only Codex cleanup to settle before unloading and resuming a retained conversation. Example: A native background command remains running when the model context limit changes from 128000 to 127000.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a demonstrated Codex continuation failure that remains on main, with convincing native-runtime proof and no actionable findings; required CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Codex plugin translates Gateway turns into native app-server thread operations; its ownership registry protects subscriptions while foreground turns and background commands still need them. flowchart TD
A[Gateway continuation] --> B[Thread lifecycle]
B --> C[Existing ownership registry]
C --> D[Background cleanup settles]
D --> E[Recheck authority and claims]
E --> F[Unsubscribe and resume native thread]
Technical reviewBest possible solution: Land the existing bounded ownership wait once required CI passes, preserving refusal while work remains protected. Do we have a high-confidence way to reproduce the issue? Current-main source still rejects this path immediately, and supplied differential Gateway logs reproduce it before the fix; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs the existing release owner with an event-driven, cancellable wait and preserves admission guards, avoiding polling, forced release, or a competing cleanup manager. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2f47962f2bdc. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +84, Tests -3. Total +81 across 7 files. Added test files: 0. View PR surface stats
Review metrics
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 (3 earlier review cycles)
Reviewed October 29, 2026, 2:48 PM ET / 18:48 UTC (Revision 4). |
Built Gateway + real native Codex cleanup orderingCandidate Native source personally inspectedSibling
This source inspection explains why subscription detachment is not physical cleanup; the runtime proof below uses the installed pinned binary rather than claiming the inspected source checkout itself was compiled. Actual shipped flow, repeated twice per snapshotActual Change only authored model
Candidate production lifecycle spans explicitly order Controls
Simplification review: retained the existing ownership observer rather than adding polling or a second cleanup manager. Listener cleanup, caller cancellation, existing interrupt deadline, and post-wait authority/client/foreground checks each protect a distinct lifetime; no safe behavior-preserving reduction identified. Existing duplicated physical-client pin checks were consolidated by the contributor. Production +104/-20 (net +84); no additional production changes made by this worker. The test-only follow-up preserves both prior refusal consumers’ ownership/subscription assertions. Zero tests run. This does not claim separate live timeout, caller-abort, authority-revocation or sibling-owner fault-injection runs; those guards were source-inspected, not presented as exercised. Revert fully undoes this lifecycle-wait change without data migration. Blast radius: native Codex cold resume when an unclaimed background-only owner remains protected; foreground/native ownership remains with its original owner. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Test-budget consolidationNo production source change. Whole-PR test delta against merge base The existing native warm-cleanup table retains real-process publication failure, protected publication failure, protected rotation, context refresh, command completion and sibling-ownership coverage. Removed the overlapping mocked publication-failure table and the separate new native cold-resume branch. The unit owner retains one three-row regression table covering settlement, caller cancellation and deadline, plus the original protected-policy refusal case. Typed refusal/protection/subscription assertions in both continuity consumers remain; the unsubscribe assertion is expressed once over the request list. No production timing, authority or foreground guard changed. Focused secretless Docker proof:
Commands/logs: Final head |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 4dc8e71. Thanks @jjjhenriksen. Codex conversations can now be resumed after background cleanup finishes. |
…nclaw#187776) fix(codex): wait for background cleanup before a cold resume of the thread Resuming a Codex conversation could fail with "claimed by active work" while a stopped turn's background cleanup was still finishing and the resume needed to unload the retained subscription. A cold resume now waits for background-only, unclaimed ownership to settle within the existing cleanup deadline, rechecks current authority and client state, then unsubscribes and resumes the original thread. Foreground claims and sibling work are still refused, nothing is force-released, and a timeout is still a refusal with a clearer error. Evidence: built Gateway with the pinned Codex app-server 0.164.0, a deterministic loopback provider and a real native background shell command. Main refused the cold continuation as claimed by active work (twice); with this change it waited about 2.4 to 2.5 s, then resumed the original thread (twice). No-pending continuation works on both refs, and during foreground work a second turn stayed queued without starting the provider. Checked against the codex app-server source at ce0323f2f2 (thread/unsubscribe and background-terminal handling). Details: openclaw#187776 (comment). Thanks @jjjhenriksen. Co-authored-by: Ayaan Zaidi <[email protected]>
fix(codex): wait for background cleanup before cold resume Backport of #187776 adapted to the release branch thread-state split after stable FRV exposed the Codex 0.164.0 active-writer race. (cherry picked from commit 4dc8e71) Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Current revision
Head
e756e6ab7c86b766b61db4a34b176b0b384f03eechanges tests only from the proven runtime head. Whole-PR tests net -3 lines, no new allocations. Retained settlement/cancellation/deadline regressions fail on frozen main; candidate targeted files pass 15/15. Consolidation and exact commands: #187776 (comment)The earlier test inventories below describe historical revisions and are superseded by this zero-growth consolidation. Production/native proof remains unchanged.
Related: #186524.
What Problem This Solves
Fixes: resuming a Codex conversation can fail with “claimed by active work” while a stopped turn’s background cleanup is still settling and refreshed creation instructions require unloading the retained subscription.
User Impact
Users can resume after background cleanup finishes without discarding the conversation. Foreground claims, sibling work, cancellation, and the existing cleanup deadline remain protected; unfinished work is never force-released.
Why This Change Was Made
Wait for unclaimed, background-only ownership to settle before the cold-resume unload, then recheck current authority and client state through the existing admission guards. Timeout remains a refusal, with an error that distinguishes unfinished background work from a foreground claim.
The ownership module owns the wait and its listener cleanup. Existing ownership and instruction helpers are reused rather than duplicated in the client adapter. This is separate from #186524’s explicit Goal Start/Resume admission fix and changes no configuration, permissions, persistence schema, or automatic-pursuit policy.
Evidence
2b62819f70eab6e5eca9490400c30c02f046961b. Production repair:6b66ecfc61ea711cf01d788d7462514e48b14e67, based on726705edca0. The follow-up changes only two tests and their 14-line test-budget allocation; runtime code is unchanged.6b66ecfc61evianode scripts/run-vitest.mjs run --config test/vitest/vitest.extension-database-workers.config.ts extensions/codex/src/app-server/thread-lifecycle.warm-cleanup.test.ts extensions/codex/src/app-server/thread-lifecycle.warm-cleanup.native.test.ts --maxWorkers=1(38.25s Vitest). Regression coverage: settlement, cancellation, and deadline paths; native background-command cleanup followed by continuation; preserved sibling ownership. Native cases use a real Codex subprocess with a synthetic test provider, not a hosted model-quality evaluation. Windows skips the native-process suite.node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo. An initial direct root-config typecheck failed on repository-wide JSX/rootDir/package-resolution configuration and is not claimed as passed.Hosted CI has not yet been verified. No merge or release inclusion is claimed.
P2 test follow-up and fresh Gateway rerun (2026-10-29)
Pushed head:
2b62819f70eab6e5eca9490400c30c02f046961b.AgentHarnessPreflightErrorand the exact background-cleanup refusal diagnostic. Protection, subscription, lifecycle, and turn-count checks remain; owner reentry now explicitly checks protection and absence of unsubscribe after refusal.pnpm test extensions/codex/src/app-server/run-attempt.native-background-outcome.test.ts extensions/codex/src/app-server/run-attempt-continuity.test.ts --maxWorkers=1(32.37s Vitest; 37.21s command wall time). Targeted extension-test typecheck, oxlint, oxfmt, and whitespace checks passed. No production timeout or sleep changes; the existing protected-cleanup refusal budget remains.CLEANUP_RESUMED_OK. This is real native-runtime/subscription-model behavior, not a synthetic provider run.The detailed earlier run below is retained as prior-run evidence; its 2,463 ms wait is distinct from the fresh 2,713 ms rerun.
Isolated real-Gateway before/after proof (2026-10-29)
Fresh built Gateway processes, separate disposable state and ports, real native Codex runtime and subscription model. Production difference is only the six-file PR commit; no integrated deployment bundle is used.
726705edca0d8cc7e39b71f4a42e40369dda93846b66ecfc61ea711cf01d788d7462514e48b14e67CLEANUP_RESUMED_OKReproduction
Actual Gateway log excerpts
Synthetic session/run/thread identifiers are retained; private paths, model identity and authentication fields are omitted.
base
candidate
Receipt checks
The first turn settled successfully on both builds with a native still-running command receipt. The candidate's final assistant reply and terminal receipt both contain CLEANUP_RESUMED_OK. Public thread_ready events match threadId and clientId across both candidate turns. Gateway log spans show the actual cleanup wait before unsubscribe and resume. Base has no successful second reply.
These are real Gateway and native-runtime/model runs, not a deterministic provider or mocked lifecycle. They do not claim all platforms/background-child variants, merge, release inclusion, or completion of the separate fine-tuning goal. Test-owned Gateway processes and disposable native auth homes are cleaned by the instance owner.
Public event and terminal-receipt excerpts
These are selected fields from the captured public Gateway events and receipts.
{"build":"base","at":"2026-10-29T16:07:15.308Z","stream":"codex_app_server.lifecycle","runId":"c901b11c-e16e-4ebd-8798-7849ddfb40e6","data":{"phase":"thread_ready","threadId":"01a1886a-5f7a-7773-980c-35660f5b2115","action":"started","clientId":"cbdde13f-2a6d-460d-bd40-08bcdab75391"}} {"build":"base","at":"2026-10-29T16:07:28.623Z","runId":"f5c801bd-bb3c-46c5-b6c4-390683ab1424","status":"error"} {"build":"candidate","at":"2026-10-29T16:08:03.224Z","stream":"codex_app_server.lifecycle","runId":"32e239b3-8830-49d4-a2e8-ef0bc05d275c","data":{"phase":"thread_ready","threadId":"01a1886b-1b4b-74e3-b518-a29539956806","action":"started","clientId":"61a454b7-fb6b-4019-96aa-d8b46ce4eaab"}} {"build":"candidate","at":"2026-10-29T16:08:19.293Z","stream":"codex_app_server.lifecycle","runId":"9f00cbd1-4ef8-46c6-8413-d16b5aefddf2","data":{"phase":"thread_ready","threadId":"01a1886b-1b4b-74e3-b518-a29539956806","action":"resumed","clientId":"61a454b7-fb6b-4019-96aa-d8b46ce4eaab"}} {"build":"candidate","at":"2026-10-29T16:08:22.654Z","runId":"9f00cbd1-4ef8-46c6-8413-d16b5aefddf2","status":"ok","terminalReply":{"disposition":"visible","text":"CLEANUP_RESUMED_OK"},"sourceReplyDelivered":true}Maintainer isolated native proof
Built Gateway and real pinned Codex app-server with deterministic local provider: main twice refuses pending-background cold resume; candidate twice waits 2424/2514 ms before unsubscribe/resume and replies on the same thread. Foreground admission and no-pending controls, source citations, proof limits and simplification rationale: #187776 (comment)
Merge danger: two-way door; no persistent migration or new configuration. Blast radius: native Codex cold resume while unclaimed background-only work remains protected.