Repository navigation
fix(codex): let idle chats resume while other chats are running - #136196
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 7:02 AM ET / 11:02 UTC. ClawSweeper reviewWhat this changesThe branch replaces whole-client lease exclusivity with per-native-thread lifecycle coordination so an idle Codex chat can resume while unrelated chats or catalog reads use the same app-server. Merge readinessKeep this protected, maintainer-owned PR open while exact-head CI and the remaining upstream contract check complete. No introduced correctness defect was identified in the reviewed owner boundaries; likely related person: steipete (high confidence, recent Codex lifecycle contributor). Priority: P2 Review scores
Verification
How this fits togetherThe Codex plugin binds an OpenClaw session or conversation to a native Codex thread on a shared app-server. Resume, compaction, conversation turns, and retirement use that binding to coordinate native subscriptions and return replies to the originating chat. flowchart LR
A[OpenClaw chat] --> B[Codex plugin]
B --> C[Session and conversation binding]
C --> D[Per-thread lifecycle queue]
D --> E[Shared Codex app-server]
E --> F[Native Codex thread]
F --> G[Chat reply and lifecycle state]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +362, Docs +15. Total +414 across 17 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. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the per-thread queue and physical-client lifetime split, then land only after exact-head CI is green and the pinned Codex request-serialization contract is directly rechecked. Do we have a high-confidence way to reproduce the issue? Yes. Current main's shared-client predicate rejects ordinary resume when unrelated leases or acquires change the client lease state, and the linked issue supplies the focused path from that predicate to resume preparation. Is this the best way to solve the issue? Unclear as a final merge verdict: the source design cleanly moves exclusion to the native-thread owner and preserves client invalidation, but direct inspection of the pinned upstream Codex serialization contract was unavailable in this environment. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 071e3b0e1099. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Addressed the review findings in cf52968a69ada9df68d78291a779684a6819c39e:
Latest focused verification: 389 tests in six files passed, including all four reproduced review regressions and the seeded lifecycle stress. Test-only CI repair verification also passed 162 tests in five files. Lint, extension/test typechecks, updated runtime build, and fresh scoped Codex autoreview passed. Production now nets +37 lines; the additional ownership scope is the cross-copy queue plus preserving supported legacy bindings. The snapshot check remains deliberately fail-closed when the prepared binding owner changes; it does not silently prepare under a different owner. Finer client-only re-admission and separate retired-client diagnostic naming remain non-blocking follow-ups, not changes smuggled into this repair. The latest red CI check on the previous head failed in Fetch pull request scan history, before scanners, with Git's missing-username/authentication error. The already-open fix is #136232; it is not duplicated here. Exact-head CI is running again on this final ownership fix. The additional authenticated restart/fan-out/compaction suite is running independently in an isolated worktree and, per explicit maintainer direction, will not delay CI-green landing; its results will be reported separately. Existing real before/after Gateway proof remains attached. |
|
Independent live/stress result on cf52968a69ada9df68d78291a779684a6819c39e: the full expanded suite did not pass. It remains a non-blocking lane per explicit maintainer direction; this is not reported as green proof. Passed: two eight-child waves with distinct native threads and exact replies (16 children total); native child bridge and parent-owned direct-input rejection; Failed: during the second post-restart compaction wave, a native command matching the requested 100,000-byte-output argv completed successfully, but the durable chat-history mirror contained a 63-character successful tool result without large-output evidence. The existing metadata-only fallback is consistent with that length, but the exact raw output/notifications were not retained before the unchanged test fixture cleaned itself up. This does not establish either a regression from this PR or a harmless flake. Sibling-deletion continuation was not reached. The worker made no production/test changes, retries, or weaker assertions. A separate output-mirroring investigation is queued to reproduce with retained raw notifications and durable state. The thread-ownership, legacy-row, and duplicate-copy fixes retain their passing targeted and primary live before/after evidence; exact-head CI is still required for landing. |
Replace shared-client sole-lease checks with target-thread coordination and exact physical-client lifetime validation. Preserve native thread IDs, policy handoff, stale-owner rejection, and precise cleanup across resume, conversation turns, compaction, and retirement. Fixes the false "another runner" failure when unrelated chats or catalog readers share a Codex app-server. Native Codex remains unchanged; internal same-thread reloads are explicitly outside this host-owned coordination. Regression, seeded concurrency stress, and real before/after Gateway proof cover the reported path. Context: #136143
Keep overload and prewrite-refusal coverage without relying on false sibling-lease contention. Assert executable-owner rejection before native writes and retain the canonical session generation in raw binding fixtures. No production behavior changes.
Keep foreign-thread ownership scans on explicit adoption, not ordinary resume of a supported binding row without sessionId. Revert the fixture-only generation stamp so the original upgrade regression remains covered. Share thread and conversation queues across duplicate dist/source plugin copies through the existing process-global singleton seam.
|
Release coordination update: the current Our parallel read-only conflict investigation stopped when the branch advanced; it made no competing source change or publication. No source/check waiver or change to the existing separately tracked compaction follow-up is implied. The earlier CI recovery used the workflow's normal second-attempt hosted-runner route. |
cf52968 to
680fef8
Compare
|
Landing update and disposition for the latest ClawSweeper review:
|
|
Merged via squash.
|
Align package, plugin, macOS, and standalone Android versions; refresh canonical native translations and approved SDK retention notes. Align managed Codex and trusted package assertions to 0.152.1, preserve the shared ACP workspace contract, and normalize native source literals at one language-aware owner. Release-only preparation retains root CHANGELOG until final Code validation. Local generated/preparation checks, regression and actual-binary probes, and all twelve independent review passes are green. This intermediate snapshot will be rebased onto current main after #136196 lands; it is not the final Code SHA.
…claw#136196) * fix(codex): let idle chats resume alongside other threads Replace shared-client sole-lease checks with target-thread coordination and exact physical-client lifetime validation. Preserve native thread IDs, policy handoff, stale-owner rejection, and precise cleanup across resume, conversation turns, compaction, and retirement. Fixes the false "another runner" failure when unrelated chats or catalog readers share a Codex app-server. Native Codex remains unchanged; internal same-thread reloads are explicitly outside this host-owned coordination. Regression, seeded concurrency stress, and real before/after Gateway proof cover the reported path. Context: openclaw#136143 * test(codex): align startup fixtures with thread ownership Keep overload and prewrite-refusal coverage without relying on false sibling-lease contention. Assert executable-owner rejection before native writes and retain the canonical session generation in raw binding fixtures. No production behavior changes. * fix(codex): preserve legacy resume and share lifecycle queues Keep foreign-thread ownership scans on explicit adoption, not ordinary resume of a supported binding row without sessionId. Revert the fixture-only generation stamp so the original upgrade regression remains covered. Share thread and conversation queues across duplicate dist/source plugin copies through the existing process-global singleton seam.
Closes #136143 — idle Codex chats falsely report another runner when unrelated work shares their app-server.
What Problem This Solves
Fixes an issue where users continuing an idle Codex chat would receive “Codex session became active in another runner” while an unrelated chat, catalog reader, or prewarm acquisition used the same app-server. Ordinary cold resume incorrectly required exclusive use of the entire shared client. Even a completed acquire/release pair could invalidate preparation.
Why This Change Was Made
Coordinate OpenClaw lifecycle mutations around the target native thread, then acquire/revalidate its binding lease. Capture the actual physical client's lifetime rather than treating unrelated pool activity as lost ownership. The same ownership order now covers resume/attachment, conversation-bound turns, compaction, and retirement; old lease-generation exclusivity, the separate compaction queue, the attachment wrapper, and caller-supplied pre-write error classification are removed.
Native status/claim checks, cancellation, stale-client rejection, configuration/policy handoff, catalog attestation, binding CAS, and exact-owner cleanup remain. A rejection by the physical pre-write callback is recorded at that callback, so cleanup distinguishes a request never sent from an indeterminate native write.
Scope: OpenClaw only; unchanged Codex 0.151.0. No process-per-chat isolation, automatic history forks, configuration knobs, persistence/schema changes, dependency changes, or native protocol additions. OpenClaw's queue does not reserve a thread against Codex-internal AgentControl reloads; the separate native-internal same-thread race remains outside this fix. The docs make that limitation explicit.
User Impact
Independent chats and catalog reads continue in parallel on a shared Codex app-server. Resuming a chat preserves its native thread identity and history rather than forking it to escape contention. Genuine target-thread activity and stale physical owners are still rejected.
Evidence
Real Gateway and Control UI
Unchanged native Codex 0.151.0, authenticated
openai/gpt-5.6-sol, fresh synthetic workspace, isolated state and port; no operator Gateway touched.ALPHA_CEDAR_731 RESUMEDbefore B's gate is released; B then repliesB_FINISHED.done.Native dependency contract
Personally inspected pinned Codex 0.151.0 source, including thread-keyed request serialization and independently drained queues and its different-key concurrency regression. An actual-binary protocol probe also completed A's policy handoff and turn while B remained active. Native configuration reload alone does not rewrite existing developer history, so OpenClaw's explicit policy injection is retained.
Regression and deterministic stress
The new owner-boundary regression failed on the original code with the exact
CodexAdoptedThreadActiveErrorbefore production edits. The final production code passed 684 tests in nine focused files, including shared-client lifetime, lifecycle/bindings, resume cleanup, compaction, retirement, conversation binding, and client cleanup. Seven selected boundary cases were rerun after test-only refinements.Seeded host-owned stress ran 100 rounds × eight thread owners in four passing local runs: 3,200 lifecycle operations. It checks same-thread predecessor ordering, unrelated lease interleavings, unchanged IDs/no starts, policy injection, exact unsubscribe accounting, replacement-claim protection, and zero leaked active/pending leases. This is deterministic OpenClaw/wire-boundary stress, not live model inference.
Validation
pnpm buildpassed, including full runtime, declarations, plugin SDK, and Control UI; zero ineffective-dynamic-import warnings. The subsequent production change was only a lint-only local-variable rename.scoped-clean, no actionable findings at its default P0-only threshold; reviewer did not run tests.Review and CI follow-through
Ordinary resume serializes its own binding without applying foreign-adoption checks to legacy rows whose top-level session generation is absent. Explicit adoption remains strict. The raw legacy fixture was preserved rather than hiding the upgrade regression. The queue is now process-global through the existing SDK singleton helper, covering duplicate dist/source module copies. Startup tests now induce real authority refusal and native overload rather than expecting the removed false lease guard.
The previous CI run's remaining failure was the unauthenticated scan-history fetch before scanners. The existing infrastructure repair is #136232; it is not duplicated here.
Production +668/−631 = +37 lines; tests +590/−228 = +362; docs +19/−4 = +15. Most raw production churn is indentation from moving the existing conversation flow under its owner scope. Net growth supplies missing owner coverage, pre-write rejection provenance, cross-copy serialization, and preserved legacy-resume behavior; the shared-client fix itself deletes more code than it adds.
attachment-2590036021.mp4