Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
Summary: In yolo mode, Codex app-server processes are not terminated when sessions end, and .codex-app-server.json binding files accumulate indefinitely. This causes quota depletion even when the Codex app is closed.
Environment:
• OpenClaw 2026.6.1
• macOS (Mac Mini host)
• Codex plugin mode: "yolo" (default)
• transport: "stdio", requestTimeoutMs: 60000, turnCompletionIdleTimeoutMs: 60000, postToolRawAssistantCompletionIdleTimeoutMs: 300000
What happens:
- Each Codex session creates a .codex-app-server.json binding file in agents/*/sessions/
- On session end, clearCodexAppServerBindingForThread() should delete the binding file and terminate the app-server process
- In yolo mode, the guardian approval flow is bypassed — including the cleanup hooks
- Binding files accumulate (3,952 stale files observed after ~2 weeks of light usage)
- Orphaned app-server processes remain alive after the Codex app is closed, continuing to meter quota
Observed symptoms:
• Closing the Codex app leaves codex app-server processes running (node .../codex app-server --listen stdio://)
• Each orphaned process burns Codex API quota while idle- Binding files in ~/.openclaw/agents//sessions/.codex-app-server.json grow without bound- First-day usage after an idle period shows massive quota depletion
Expected behavior:
• Session-end cleanup should run regardless of yolo/guardian mode — binding file deletion is hygiene, not a security policy decision
• Processes should be terminated when the controlling session ends
• Or: a background reaper should clean up binding files and processes older than the idle timeout
Workaround in place: A nightly 4 AM cron (codex-health-check) monitors and auto-cleans, but this is a band-aid.
Suggested fix: Either (a) ensure clearCodexAppServerBindingForThread runs on session end in yolo mode, or (b) add a startup/idle sweep that reaps binding files and processes for sessions that ended abnormally.
Steps to reproduce
- Start a Codex session via OpenClaw (Studio or CLI)
- Close the Codex app
- Observe — codex app-server processes remain alive: ps aux | grep 'codex app-server' | grep -v grep
- Repeat step 1-2 multiple times over days/weeks
- Observe binding file accumulation: find ~/.openclaw/agents//sessions -name '.codex-app-server.json' | wc -l
Expected behavior
• Closing the Codex app should terminate the codex app-server child processes
• Session-end cleanup (clearCodexAppServerBindingForThread) should run regardless of yolo/guardian mode
• Binding files should be deleted when sessions endActual behavior:
• codex app-server processes persist after app close, continuing to meter Codex API quota
• .codex-app-server.json binding files accumulate indefinitely (3,952 files observed after ~2 weeks of light usage)
• yolo mode skips the guardian cleanup hooks that would otherwise terminate processes and clean binding files
Actual behavior
Closing the Codex app leaves codex app-server processes running — they persist indefinitely as orphans, continuing to meter Codex API quota. .codex-app-server.json binding files accumulate without bound in ~/.openclaw/agents/*/sessions/ (3,952 files observed after ~2 weeks of light usage). The yolo mode skips the guardian cleanup hooks that would otherwise call clearCodexAppServerBindingForThread and terminate the processes on session end. Each orphaned process pair burns quota from the moment the app closes until manually killed.
OpenClaw version
2026.6.1
Operating system
macOS Darwin 25.3.0 (Mac Mini)
Install method
npm global / pnpm
Model
openai/gpt-5.5 via Codex runtime
Provider / routing chain
Codex plugin → codex agent runtime → openai/gpt-5.5 model
Additional provider/model setup details
• Codex plugin config: mode: "yolo", transport: "stdio", requestTimeoutMs: 60000, turnCompletionIdleTimeoutMs: 60000
• 3,952 stale binding files found in ~/.openclaw/agents/*/sessions/
• Nightly health check cron (codex-health-check, 4 AM Pacific) created as temporary workaround
• This is not a misconfiguration — yolo mode is the documented default; cleanup should not be policy-gated
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 9, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 12:32 PM ET / 16:32 UTC.
Summary
Keep open: current main has a credible one-shot app-server process teardown fix from PR #91767, but the stale sidecar half of the report remains unresolved because approved
.codex-app-server.jsonfiles are still preserved as active bound-thread state and no lifecycle-owned stale sweep or live macOS current-main proof shows the reported accumulation path is fixed.Reproducibility: no. high-confidence live reproduction was run against current main; source inspection confirms the remaining sidecar-policy gap, while PR #91767 live proof only covers one-shot process teardown.
Ways to help us reproduce this
Next step
Manual maintainer review is needed to define stale-sidecar lifecycle policy and collect live macOS proof before changing cleanup behavior.
Review details
Best possible solution:
Keep the one-shot teardown fix, define how to distinguish active/resumable Codex sidecars from stale ones, then add lifecycle-owned stale cleanup with live process and file-count proof.
Do we have a high-confidence way to reproduce the issue?
No high-confidence live reproduction was run against current main; source inspection confirms the remaining sidecar-policy gap, while PR #91767 live proof only covers one-shot process teardown.
Is this the best way to solve the issue?
No for the previously proposed approval-callback fix: clearing approved sidecars removes active bound-thread state, so the safer solution is lifecycle-owned stale cleanup that preserves valid bindings.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against c2ee9b0be8ae.
Label changes
Label changes:
clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P1: The issue reports a real Codex lifecycle leak that can leave app-server processes running and degrade agent reliability or quota usage.impact:session-state: The remaining work is about Codex session binding sidecars and preserving or cleaning per-session thread state correctly.impact:other: The report also describes orphaned local processes and quota depletion, which is meaningful maintainer-visible runtime impact outside the narrower owned labels.Evidence reviewed
Acceptance criteria:
codex app-server --listen stdio://children remain after teardown.What I checked:
handleCodexConversationBindingResolvedreturns unless the status isdenied, so approved/yolo binding resolutions do not clear the sidecar on current main. (extensions/codex/src/conversation-binding.ts:321, c2ee9b0be8ae)thread/startorthread/resume, then later bound turns read that sidecar and throw if no thread binding exists. (extensions/codex/src/conversation-binding.ts:487, c2ee9b0be8ae)clearCodexAppServerBindingandclearCodexAppServerBindingForThreadunlink the sidecar; this path does not terminate Codex app-server processes. (extensions/codex/src/app-server/session-binding.ts:430, c2ee9b0be8ae)closeAndWaitcleanup for CLI/gateway runs, with live proof that no app-server children remained after that smoke run. (extensions/codex/src/app-server/run-attempt.ts:1347, 870ec6dee291)cleanupBundleMcpOnRunEnd: true, which is the process-teardown path added by PR Fix one-shot Codex app-server teardown #91767. (src/commands/agent-via-gateway.ts:714, c2ee9b0be8ae)Likely related people:
extensions/codex/src/conversation-binding.ts,extensions/codex/src/app-server/session-binding.ts,extensions/codex/src/app-server/run-attempt.ts)extensions/codex/src/app-server/run-attempt.ts,src/commands/agent-via-gateway.ts,packages/gateway-protocol/src/schema/agent.ts)src/plugins/conversation-binding.ts,extensions/codex/src/app-server/run-attempt.ts,docs/plugins/codex-harness.md)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.steipete commentedon Jul 18, 2026
Closing as fixed on main. The binding-file half is structurally resolved: app-server thread bindings moved into SQLite plugin state in #101210 (
0d981095d430), so.codex-app-server.jsonsidecars are no longer written at all;openclaw doctor --fixmigrates and archives existing legacy sidecar files into the bounded store (extensions/codex/src/migration/session-binding-sidecars.ts). The process half is resolved by the attempt-lifecycle cleanup and liveness-retirement work (ca3f247eb215,80b2b709ca8c, plus the earlier one-shot teardown) — cleanup is not gated on the guardian/yolo approval path. Stress evidence from 2026-07-16: three serial plus four parallel codex live suites on a clean box left zero orphanedcodex app-serverprocesses.If you still see orphaned app-server processes or growing sidecar counts on a current release after
doctor --fix, please open a fresh issue withpsoutput and the OpenClaw version; hard-killing the gateway mid-turn is tracked separately in #107721.