Skip to content

fix: gateway kill leaves Codex tool processes running - #107721

Merged
steipete merged 2 commits into
openclaw:mainfrom
mingyooagi:codex/codex-cancel-background-terminals
Aug 29, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
mingyooagi:codex/codex-cancel-background-terminals

Conversation

@mingyooagi

@mingyooagi mingyooagi commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Stopping an active OpenClaw Codex run could leave its native shell command running after the turn reported interrupted. This remains reproducible on the current Codex app-server: a command continued writing its heartbeat after the matching turn/completed event.

Codex deliberately separates turn interruption from terminal termination. Directly checked upstream rust-v0.150.1: abort_all_tasks cancels the turn, while native terminal cleanup and identity-checked terminal termination are separate operations. Existing thread/unsubscribe only releases the connection subscription; it does not terminate native terminals. The terminal list returns the complete inventory when limit is omitted. The list/terminate protocol and inventory default were also verified in rust-v0.144.4, the original PR's dependency version, and the supported external minimum rust-v0.149.0 plus rust-v0.149.1: RPC types, list/terminate owners, and full-inventory default. Those relevant source files are identical between 0.149.0 and 0.149.1.

Changes

Reworked the original PR on current main, which already contains process-scope lifecycle and app-server retirement improvements. The remaining repair belongs in the Codex plugin's attempt cancellation owner:

  • Wait for the exact interrupted turn to finish, then list and terminate that thread's native background terminals through Codex's API.
  • Join terminal cleanup before finalizing the attempt or releasing its subscription and lease. Bound the terminal RPC sequence to five seconds and verify no terminals remain.
  • Report an unconfirmed interrupt or failed cleanup, while still releasing attempt resources. A terminal that exits naturally between listing and termination is accepted after inventory verification.
  • Freeze cancellation admission synchronously when cleanup starts, including after a finalization error, so late cancellation cannot replace the awaited cleanup or hide the original failure. This moves the existing freeze instead of adding another lifecycle flag.
  • Preserve other threads on the shared app-server, existing timeout handling, and deliberately backgrounded gateway_process jobs. Document the ownership boundary and cleanup failure behavior.

The earlier generic process-scope, PID/PGID, Windows fallback, and whole-app-server cancellation changes are removed. They were unnecessary for the remaining owner defect and introduced stale process-identity and peer-cancellation risks. No core supervisor, configuration, dependency, or persistence changes remain.

Production delta: +80/-3 (net +77); tests/support: +183/-48 (net +135); docs: +8. Production growth supplies the missing native terminal-owner operation and its awaited lifecycle; generic host process scopes cannot replace that protocol contract. Thanks @mingyooagi for the report and initial implementation; co-author credit is preserved.

Evidence

  • Regressions reproduced before repair: the original path unsubscribes without requesting the terminal inventory; the late-cancellation case starts a new interrupt during unsubscribe and replaces the original projection error. Both pass after repair.
  • 413 tests across seven Codex suites pass, covering attempt lifecycle, exact-turn cancellation, cleanup failure/timeout, hooks, native hook relay, turn watches, and shared-client behavior.
  • Production and test extension typechecks, type-aware lint, formatting, max-lines/type-assertion guards, and git diff --check pass. Fresh independent Codex autoreview found no actionable P0–P2 findings.
  • Real Codex 0.150.1 with a local fixture Responses endpoint reproduced the bug: the target stayed alive and its heartbeat advanced after interruption. Thread-scoped termination stopped it while a concurrent peer continued.
  • Authenticated live OpenAI run through production runCodexAppServerAttempt, real Codex 0.150.1, isolated state, two threads sharing the same app-server: cancellation settled in 170 ms; the target process was already dead, its completion marker was absent, and the peer remained alive/listed with its heartbeat advancing and turn still active. No owned test processes survived cleanup. This exercises the actual production attempt and provider, not a mocked app-server.

Sanitized authenticated live result:

{
  "result": "PASS",
  "codexVersion": "0.150.1",
  "platform": "darwin",
  "cancellationMs": 170,
  "terminalOutcome": "aborted",
  "targetAliveWhenAttemptSettled": false,
  "targetCompletionMarkerExists": false,
  "peerAlive": true,
  "peerInventoryCount": 1,
  "peerHeartbeatAdvanced": true,
  "peerTurnCompleted": false,
  "survivingOwnedProcesses": 0
}

Full Gateway and Control UI proof

On final head 21d3b2efb193e138190b15349c4245444a4e9da6, built the production runtime and UI, launched the normal Gateway CLI with isolated state, and started two conversations through chat.send. Both native ticking commands were observed as children of the same real Codex 0.150.1 app-server. Clicked the rendered Stop generating button in Chrome, then repeated in an isolated Playwright Chromium context with a 6.32-second video: its Working/Active state disappeared, its command exited, and no completion marker was written. The peer stayed active and its heartbeat advanced. In the recorded repeat, the UI sent chat.abort, showed Interrupted, and the target process was confirmed gone within 313 ms while the peer kept running. All task processes, the browser, and listeners were then cleaned up.

This full Gateway/UI lane uses a local fixture Responses model; it is separate from the authenticated provider/production-attempt proof above. Runtime and UI builds passed after linking the worktree's missing UI dependency directory to the already-installed matching dependencies; no packages or operator state were changed.

{
  "result": "PASS",
  "entry": "Control UI Stop generating -> chat.abort",
  "uiAndProcessConfirmationMs": 313,
  "sameCodexAppServer": true,
  "targetAlive": false,
  "targetCompletionMarkerExists": false,
  "targetChatState": "aborted",
  "targetLifecycleStatus": "cancelled",
  "targetWaitStatus": "error",
  "peerAlive": true,
  "peerHeartbeatBefore": 307,
  "peerHeartbeatAfter": 308,
  "peerTerminalEvents": 0,
  "survivingOwnedProcesses": 0
}

agent.wait retains the existing cancellation projection (status: error); chat and lifecycle carry the structured aborted/cancelled state. This is unchanged core behavior, not a terminal-cleanup failure.

Review follow-through

The previous ClawSweeper review was against the superseded 42-file implementation. Its protocol-contract request is addressed by direct upstream source references above; its shared-client destruction and failed-scope recovery findings are addressed by removing those paths. The Windows-specific process-tree changes were also removed, so their requested containment proof does not apply to this rewritten patch. Native Windows execution remains an explicitly untested platform.

The refreshed review also requested a maintainer contract check because its environment could not obtain Codex source. That check was completed directly: the methods exist in the supported dependency, omitted limit returns the full inventory, and terminated: false requires the final inventory check to distinguish a natural exit from failed termination. No equivalent confirmed lifecycle API absorbs the missing operation: unsubscribe only drops a subscription, while thread removal shuts down the conversation. The existing backgroundTerminals/clean only submits a queued operation; SessionIo::submit_with_id acknowledges enqueueing, not terminal exit. Using it would require another asynchronous completion/polling mechanism, whereas per-terminal termination already supplies the awaitable owner contract. Cleanup failures intentionally remain visible errors after resource release; reporting ordinary cancellation would conceal unconfirmed process cleanup. The regression and existing cancellation/transport suites cover this boundary.

Proof boundaries

The full Gateway/Control UI proof is now complete; the earlier source-loader startup limitation was resolved by the normal built runtime. Before/after captures and the recorded Stop flow were inspected locally. Public image/video publication is blocked by the test workstation's capture-sharing policy: upload authorization for that environment was not established, so media stays local and the sanitized observed trace is supplied above. Native Windows behavior was not live-tested. The guarantee follows Codex's terminal ownership; it does not claim cleanup of arbitrary commands that deliberately detach from that ownership. This PR does not add a whole-server kill fallback when thread cleanup cannot be confirmed.

AI-assisted: yes.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: codex size: XL triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 14, 2026
@mingyooagi
mingyooagi force-pushed the codex/codex-cancel-background-terminals branch 2 times, most recently from 69311cf to 1f2974b Compare July 14, 2026 19:17
@mingyooagi mingyooagi changed the title Propagate Gateway cancellation through Codex tool process trees fix: gateway kill leaves Codex tool processes running Jul 14, 2026
@mingyooagi
mingyooagi force-pushed the codex/codex-cancel-background-terminals branch from 1f2974b to 9cafd35 Compare July 14, 2026 19:58
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 15, 2026
@clawsweeper

clawsweeper Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 10:09 PM ET / August 29, 2026, 02:09 UTC.

ClawSweeper review

What this changes

The PR makes explicit Codex-run cancellation wait for the matching turn, terminate only that thread’s native background terminals, and join cleanup before releasing attempt resources.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 5 items remain

No introduced lifecycle defect was found, but this dependency-backed PR cannot receive a merge/proof-sufficiency verdict here because the required sibling Codex source is unavailable for direct protocol verification.

Priority: P1
Reviewed head: 21d3b2efb193e138190b15349c4245444a4e9da6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The rewritten patch has focused lifecycle coverage and credible production-path output, with merge readiness held only for direct dependency-contract verification.
Proof confidence 🦞 diamond lobster (5/6) Needs stronger real behavior proof before merge: The PR body supplies a sanitized authenticated production-attempt trace on Codex 0.150.1 showing the target process gone while a peer survives, but this reviewer cannot certify proof sufficiency because the required direct Codex protocol-source check is unavailable; this is a reviewer environment limitation, not a request for contributor proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body supplies a sanitized authenticated production-attempt trace on Codex 0.150.1 showing the target process gone while a peer survives, but this reviewer cannot certify proof sufficiency because the required direct Codex protocol-source check is unavailable; this is a reviewer environment limitation, not a request for contributor proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Introduced lifecycle owner: The new explicit-cancellation path waits for the exact turn, then invokes thread-scoped terminal cleanup before completing the attempt.
Teardown ordering: Finalization and cleanup both join abort cleanup; cleanup preserves resource release on failure and rethrows afterward.
Boundary regression coverage: The added test holds cancellation open through the exact completion and terminal RPCs, rejects cleanup failure after teardown, and keeps the shared client open.
Findings None None.
Security None None.

How this fits together

The Codex plugin runs app-server turns for OpenClaw agents. Cancellation flows from the attempt lifecycle to Codex’s thread-scoped terminal API before the route, subscription, and client lease are released.

flowchart LR
A[Gateway cancellation] --> B[Codex attempt]
B --> C[Interrupt matching turn]
C --> D[Thread terminal inventory]
D --> E[Terminate thread terminals]
E --> F[Verify inventory empty]
F --> G[Release attempt resources]
Loading

Decision needed

Question Recommendation
Can a maintainer with access to the sibling Codex checkout verify and record the list/terminate RPC contract for OpenClaw’s supported external app-server range before merge? Verify supported Codex contracts: Check direct Codex 0.149.x and 0.150.1 source/types for the two RPCs and their inventory semantics, then retain this focused repair.

Why: The patch’s correctness depends on a third-party app-server protocol, and local policy requires direct sibling-source inspection that this read-only environment cannot perform.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body supplies a sanitized authenticated production-attempt trace on Codex 0.150.1 showing the target process gone while a peer survives, but this reviewer cannot certify proof sufficiency because the required direct Codex protocol-source check is unavailable; this is a reviewer environment limitation, not a request for contributor proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Existing installations may use the supported external Codex 0.149.x binary; direct source verification is still needed to establish that both new terminal RPCs and their pagination/result semantics are available there.
  • Resolve merge risk (P1) - A cleanup RPC failure now makes an explicit cancellation reject after bounded cleanup rather than return an ordinary aborted result; this is intentional in the patch but needs contract-confirmed maintainer acceptance.
  • Complete next step (P2) - A maintainer must verify the dependency protocol directly; there is no narrow source change for an automated repair worker to make.
Agent review details

Security

None.

PR surface

Source +80, Tests +132, Docs +8. Total +220 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 83 3 +80
Tests 3 180 48 +132
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 271 51 +220

Review metrics

Metric Value Why it matters
Production versus tests production +80/-3; tests/support +183/-48; docs +8 The positive production growth implements a new dependency-owned terminal-cleanup operation and its lifecycle joins; tests cover ordering, failure, and timeout paths.

Merge-risk options

Maintainer options:

  1. Verify external-binary compatibility (recommended)
    Confirm the new terminal RPCs directly against the supported Codex 0.149.x and managed 0.150.1 implementations before merge.
  2. Pause for protocol evidence
    Keep the PR open until a reviewer can inspect the authoritative Codex contract instead of accepting an unverified external-binary assumption.

Technical review

Best possible solution:

Keep the thread-owned cleanup design, but cite direct Codex 0.149.x and 0.150.1 source/types for the list and terminate RPC contract before landing.

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

No independent current-main runtime reproduction was possible in this read-only environment. Current-main source shows the direct interrupt-completion path, and the PR supplies a production-path live trace, but its Codex contract was not independently inspectable.

Is this the best way to solve the issue?

Unclear: OpenClaw lifecycle reading supports thread-scoped cleanup as the right owner boundary, but direct Codex protocol verification is required before calling it the best confirmed solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bf94ec5e7e5f.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Needs stronger real behavior proof before merge: The PR body supplies a sanitized authenticated production-attempt trace on Codex 0.150.1 showing the target process gone while a peer survives, but this reviewer cannot certify proof sufficiency because the required direct Codex protocol-source check is unavailable; this is a reviewer environment limitation, not a request for contributor proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: needs maintainer proof decision.

Label justifications:

  • P1: An explicit run cancellation can otherwise leave a Codex-owned tool process active.
  • merge-risk: 🚨 compatibility: The PR adds protocol calls while OpenClaw supports externally supplied Codex binaries from 0.149.0.
  • merge-risk: 🚨 availability: Cleanup failure now turns a cancellation into an error after bounded teardown.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Needs stronger real behavior proof before merge: The PR body supplies a sanitized authenticated production-attempt trace on Codex 0.150.1 showing the target process gone while a peer survives, but this reviewer cannot certify proof sufficiency because the required direct Codex protocol-source check is unavailable; this is a reviewer environment limitation, not a request for contributor proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: Authored both current PR commits and is the strongest recent contributor to the app-server attempt lifecycle. (role: recent area contributor; confidence: high; commits: 217b3665f4dd, 21d3b2efb193; files: extensions/codex/src/app-server/attempt-client-cleanup.ts, extensions/codex/src/app-server/run-attempt-active-turn.ts)
  • Vincent Koc: Current main’s pre-PR interrupt-completion behavior is attributed to the preceding lifecycle refactor. (role: recent adjacent contributor; confidence: medium; commits: fae557490851; files: extensions/codex/src/app-server/run-attempt-active-turn.ts)

Rank-up moves

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

  • Have a reviewer with sibling Codex source access cite the supported-version list and terminate RPC contract before merge.

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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-07-15T07:42:20.123Z sha b1b44a9664e495b6b9741ef2e0d9dc50258951d4 :: needs real behavior proof before merge. :: [P1] Do not retain every exited Windows tree as permanently unprovable
  • reviewed 2026-07-15T09:43:28.049Z sha b1b44a9664e495b6b9741ef2e0d9dc50258951d4 :: needs real behavior proof before merge. :: [P1] Do not retain every exited Windows tree as permanently unprovable
  • reviewed 2026-07-30T11:26:33.444Z sha b1b44a9664e495b6b9741ef2e0d9dc50258951d4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-02T00:15:44.434Z sha b1b44a9664e495b6b9741ef2e0d9dc50258951d4 :: needs real behavior proof before merge. :: [P1] Verify the added Codex background-terminal RPC contract
  • reviewed 2026-08-29T02:00:38.800Z sha 217b366 :: needs maintainer review before merge. :: none

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 28, 2026
Codex turn interruption deliberately leaves native background terminals
running. Wait for the matching turn to stop, terminate that thread's
terminals through the app-server API, and join cleanup before releasing
the attempt. Surface cleanup failures without retiring shared peer threads.

Keep existing host process scopes and background gateway jobs unchanged.
Verified with 412 focused tests and an authenticated live Codex run with a
concurrent peer thread on the same app-server.

Co-authored-by: Ming Yoo <[email protected]>
@steipete
steipete force-pushed the codex/codex-cancel-background-terminals branch from b1b44a9 to 217b366 Compare August 29, 2026 01:42
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed agents Agent runtime and tooling size: XL labels Aug 29, 2026
@steipete steipete self-assigned this Aug 29, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 29, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 29, 2026
Close cancellation admission synchronously when cleanup takes ownership,
including when finalization throws before freezing its terminal outcome.
This keeps late aborts from replacing the joined cleanup promise during
resource release or masking the original finalization error.

Move the existing terminal freeze instead of adding another lifecycle flag.
Verified the regression fails before the change; all 413 Codex tests pass.
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

The PR is rewritten on current main. The body now includes direct Codex 0.150.1/0.144.4 source verification, inspectable authenticated live observations, 413 passing tests, and the resolution of the previous shared-client and process-scope findings. The remaining repair uses thread-owned native terminal RPCs and freezes cancellation admission before attempt teardown; the destructive fallback and Windows-specific process-tree changes are gone.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 29, 2026
@steipete
steipete merged commit cde3458 into openclaw:main Aug 29, 2026
379 of 381 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
* fix(codex): stop native terminals on run cancellation

Codex turn interruption deliberately leaves native background terminals
running. Wait for the matching turn to stop, terminate that thread's
terminals through the app-server API, and join cleanup before releasing
the attempt. Surface cleanup failures without retiring shared peer threads.

Keep existing host process scopes and background gateway jobs unchanged.
Verified with 412 focused tests and an authenticated live Codex run with a
concurrent peer thread on the same app-server.

Co-authored-by: Ming Yoo <[email protected]>

* fix(codex): freeze cancellation before attempt teardown

Close cancellation admission synchronously when cleanup takes ownership,
including when finalization throws before freezing its terminal outcome.
This keeps late aborts from replacing the joined cleanup promise during
resource release or masking the original finalization error.

Move the existing terminal freeze instead of adding another lifecycle flag.
Verified the regression fails before the change; all 413 Codex tests pass.

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Ming Yoo <[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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M stale Marked as stale due to inactivity status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants