Skip to content

fix(codex): the turn after an interrupt waits for every other active Codex chat - #165487

Merged
steipete merged 1 commit into
mainfrom
codex/stab-codex-interrupt-stall
Oct 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/stab-codex-interrupt-stall

Conversation

@steipete

@steipete steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: interrupting one Codex-runtime chat (Stop + send, or queueMode: "interrupt") makes the follow-up turn wait until every other active Codex chat on the same app-server finishes — 84 s, and once 215 s, in live runs — because cleanup retires the shared app-server process after a perfectly normal interrupt.

User Impact

User impact: after an interrupt, the replacement turn starts right away (0.7 s live) even while other Codex chats keep working, and those other chats are no longer pushed onto a retired process. Genuinely failed cleanup still retires the client as before.

Why This Change Was Made

Interrupted turns intentionally leave settledTurnStatus unset, so attempt cleanup releases their thread subscription. That unsubscribe ran under the attempt's foreground connection.withCurrent, whose authority is already cancelled by the interrupt, so the unsubscribe reported "not released" and cleanup treated it as an unsafe subscription: it closed and retired the shared client. The next turn on that thread then waited for the retired process to exit, which cannot happen while sibling chats hold leases. Unsubscribe now runs under the attempt's existing cleanup authority (cleanupAuthority.withCurrent), which keeps the host/session lineage checks and still retires the client when an unsubscribe genuinely fails. Writer barrier and ring-zero/client-bound rules are unchanged.

Evidence

Live, dev Gateway (OpenAI provider, @openai/codex 0.160.0 managed app-server): Codex session Y runs a 90 s sleep; Codex session X is interrupted mid-turn.

Build Old run stopped Replacement turn started Sibling Y
main 0.13 s 84.1 s (released ~0.5 s after Y finished) blocks X
this branch 0.13 s 0.68 s still running, unaffected

Instrumented main showed the precursor exactly: interrupt confirmed in 13 ms, then cleanupCodexAttempt → releaseThreadSubscription → closeCodexStartupClientBestEffort → retireSharedCodexAppServerClientIfCurrent; the replacement's resume then waited in previous.release(true) for the retired process exit. Native 0.160.0 semantics for thread/unsubscribe and thread/closed were checked against the Codex source.

TMPDIR=… pnpm test extensions/codex/src/app-server/run-attempt.subscription.test.ts --maxWorkers=1
main (fix line reverted): new regression fails — X blocked while Y active
branch: 12 passed (45.2 s wall incl. compile; new case 4.7 s)

196 related Codex plugin tests pass (interrupt cleanup, client runtime, shared client, compaction). Codex package types, extension lint, formatting, docs checks pass.

Production +1/−1; tests +73; docs +3.

Use the resource owner's cleanup authority for thread unsubscription. An
interrupted foreground run no longer rejects its required cleanup before the
native request and needlessly retires the app-server shared with other chats.
Keep host/session lineage checks and genuine unsafe-subscription retirement.

Prove that the next turn resumes the same thread while a sibling stays active.
The regression fails with the production change reverted; 196 related tests
and the Codex package typecheck pass. Document the parallel-chat behavior.
@clawsweeper

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

@steipete
steipete marked this pull request as ready for review October 5, 2026 09:38
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: S labels Oct 5, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 5:44 AM ET / 09:44 UTC.

ClawSweeper review

What this changes

The PR lets interrupted Codex chats release their subscription without retiring the app-server shared with other chats, and adds regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. The focused repair and supplied live evidence support the intended behavior, and no blocking patch defect was found.

Priority: P1
Reviewed head: b99908550f1a3db2c368facdc6e43bd717ee45cd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small owner-level repair has relevant live observations and a credible concurrent-chat regression.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied live dev-Gateway comparison exercises interrupted-attempt cleanup against managed Codex 0.160.0 and shows the replacement starting in 0.68 seconds while the sibling continues. The transport regression supplements that observation; no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied live dev-Gateway comparison exercises interrupted-attempt cleanup against managed Codex 0.160.0 and shows the replacement starting in 0.68 seconds while the sibling continues. The transport regression supplements that observation; no stored-data contract changes.
Evidence reviewed 8 items Pinned introduction and merge result: The merge-base-to-head diff changes only the unsubscribe authority, its concurrent-chat regression, and runtime documentation. The verified test merge against its recorded main parent preserves that same production change.
Current main still needs the repair: Fetched main still passes connection.withCurrent to unsubscribe, which retains foreground cancellation. The shared-client retirement fallback remains reachable when that admission rejects. Canonical searches did not identify a merged replacement for this specific concurrent-chat stall.
Cleanup authority retains final-effect safeguards: The existing cleanup authority checks active host capability and resource lifetime while carrying the original session lineage. Its withCurrent implementation rereads and validates lineage immediately before the synchronous wire callback. Client request admission also checks transport validity and pending-request state; exact thread claims and expired-settlement handling remain unchanged.
Findings None None.
Security None None.

How this fits together

OpenClaw's Codex plugin sends chat turns to a shared Codex app-server. Attempt cleanup releases thread subscriptions and client leases so subsequent turns can resume without disrupting other chats.

flowchart TD
  A[Chat interrupted] --> B[Attempt cleanup]
  B --> C[Host and session authority]
  C --> D[Thread unsubscribe]
  D --> E{Cleanup confirmed?}
  E -->|Yes| F[Keep shared client and resume chat]
  E -->|No| G[Retire unsafe client]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +73, Docs +3. Total +76 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 73 0 +73
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 77 1 +76

Review metrics

Metric Value Why it matters
Replacement-turn latency 84.1 s → 0.68 s in supplied live runs The observed recovery removes the wait for an unrelated active chat.

Technical review

Best possible solution:

Use the existing resource-owned cleanup authority to preserve concurrent chats while retaining retirement for genuinely unsafe cleanup.

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

Yes: interrupt one Codex chat while a sibling holds the shared client, then send a replacement turn. Current-main source and the supplied live trace establish the path; this review did not execute it.

Is this the best way to solve the issue?

Yes: reusing the existing cleanup authority repairs cancellation handling at its owner without adding another lifecycle mechanism or weakening host/session lineage validation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 500c95aaa373.

Labels

Label changes:

  • add P1: Live evidence shows ordinary interruption can stall replacement Codex turns for over a minute while unrelated chats remain active.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied live dev-Gateway comparison exercises interrupted-attempt cleanup against managed Codex 0.160.0 and shows the replacement starting in 0.68 seconds while the sibling continues. The transport regression supplements that observation; no stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied live dev-Gateway comparison exercises interrupted-attempt cleanup against managed Codex 0.160.0 and shows the replacement starting in 0.68 seconds while the sibling continues. The transport regression supplements that observation; no stored-data contract changes.

Label justifications:

  • P1: Live evidence shows ordinary interruption can stall replacement Codex turns for over a minute while unrelated chats remain active.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied live dev-Gateway comparison exercises interrupted-attempt cleanup against managed Codex 0.160.0 and shows the replacement starting in 0.68 seconds while the sibling continues. The transport regression supplements that observation; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied live dev-Gateway comparison exercises interrupted-attempt cleanup against managed Codex 0.160.0 and shows the replacement starting in 0.68 seconds while the sibling continues. The transport regression supplements that observation; no stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge result: The merge-base-to-head diff changes only the unsubscribe authority, its concurrent-chat regression, and runtime documentation. The verified test merge against its recorded main parent preserves that same production change. (extensions/codex/src/app-server/run-attempt-resources.ts:502, b99908550f1a)
  • Current main still needs the repair: Fetched main still passes connection.withCurrent to unsubscribe, which retains foreground cancellation. The shared-client retirement fallback remains reachable when that admission rejects. Canonical searches did not identify a merged replacement for this specific concurrent-chat stall. (extensions/codex/src/app-server/run-attempt-resources.ts:502, 500c95aaa373)
  • Cleanup authority retains final-effect safeguards: The existing cleanup authority checks active host capability and resource lifetime while carrying the original session lineage. Its withCurrent implementation rereads and validates lineage immediately before the synchronous wire callback. Client request admission also checks transport validity and pending-request state; exact thread claims and expired-settlement handling remain unchanged. (src/agents/harness/native-session/binding-authority.ts:137, b99908550f1a)
  • Live after-fix behavior: The captured PR body reports a dev Gateway using the OpenAI provider and managed Codex 0.160.0: chat Y runs a 90-second command while chat X is interrupted. Replacement startup improves from 84.1 seconds on main to 0.68 seconds on the branch, while Y remains active. The supplied failure trace connects cleanup's rejected unsubscribe to shared-client retirement and the replacement's wait for process release. (b99908550f1a)
  • Meaningful concurrent-chat regression: The added case runs two production attempts through the existing lifecycle transport harness, interrupts the first, verifies its unsubscribe, resumes the same thread before the sibling settles, and completes both. The body reports that reverting the production line makes this regression fail; the focused suite passes 12 cases and 196 related tests pass. These executions were supplied evidence, not rerun during this read-only review. (extensions/codex/src/app-server/run-attempt.subscription.test.ts:38, b99908550f1a)
  • Required native dependency contract inspected: The changed path sends thread/unsubscribe, and the PR explicitly claims compatibility with Codex 0.160.0 unsubscribe semantics. Personally inspected native code removes this connection's subscription from the named thread and returns unsubscribed, notSubscribed, or notLoaded. GitHub's release-tag object resolves to the inspected checkout SHA, verifying repository identity. (codex-rs/app-server/src/request_processors/thread_processor.rs:1020, a956835d0207)

Likely related people:

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

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 4c34d8e into main Oct 5, 2026
174 of 176 checks passed
@steipete
steipete deleted the codex/stab-codex-interrupt-stall branch October 5, 2026 09:54
@steipete

steipete commented Oct 5, 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 6, 2026
…claw#165487)

Use the resource owner's cleanup authority for thread unsubscription. An
interrupted foreground run no longer rejects its required cleanup before the
native request and needlessly retires the app-server shared with other chats.
Keep host/session lineage checks and genuine unsafe-subscription retirement.

Prove that the next turn resumes the same thread while a sibling stays active.
The regression fails with the production change reverted; 196 related tests
and the Codex package typecheck pass. Document the parallel-chat behavior.
RomneyDa pushed a commit that referenced this pull request Oct 6, 2026
)

Use the resource owner's cleanup authority for thread unsubscription. An
interrupted foreground run no longer rejects its required cleanup before the
native request and needlessly retires the app-server shared with other chats.
Keep host/session lineage checks and genuine unsafe-subscription retirement.

Prove that the next turn resumes the same thread while a sibling stays active.
The regression fails with the production change reverted; 196 related tests
and the Codex package typecheck pass. Document the parallel-chat behavior.

(cherry picked from commit 4c34d8e)
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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant