Skip to content

[Bug]: Codex yolo mode leaks app-server processes and binding files #91537

Closed

Description

@mikealford-kuon

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:

  1. Each Codex session creates a .codex-app-server.json binding file in agents/*/sessions/
  2. On session end, clearCodexAppServerBindingForThread() should delete the binding file and terminate the app-server process
  3. In yolo mode, the guardian approval flow is bypassed — including the cleanup hooks
  4. Binding files accumulate (3,952 stale files observed after ~2 weeks of light usage)
  5. 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

  1. Start a Codex session via OpenClaw (Studio or CLI)
  2. Close the Codex app
  3. Observe — codex app-server processes remain alive: ps aux | grep 'codex app-server' | grep -v grep
  4. Repeat step 1-2 multiple times over days/weeks
  5. 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

Activity

  1. clawsweeper commented on Jun 9, 2026

    @clawsweeper
    Contributor

    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.json files 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

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.
    • Include redacted logs or terminal output.

    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:

    • No live macOS current-main reproduction was run, so the remaining process-leak claim after PR Fix one-shot Codex app-server teardown #91767 is not independently proven here.
    • The reported sidecar count may include a mix of valid resumable bindings and stale bindings; deleting without classification can break bound Codex conversations.
    • A stale-sidecar cleanup path needs an owner and lifecycle boundary, because the unsafe approval-callback approach has already been shown to remove active session state.

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

    Label changes

    Label changes:

    • add 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:

    • Run a live macOS yolo Codex app-server session through OpenClaw, close/end the session, and verify no lingering codex app-server --listen stdio:// children remain after teardown.
    • Verify a valid approved bound Codex conversation can still receive a later bound message after any cleanup changes.
    • Create or preserve representative stale sidecars and prove the cleanup removes stale files without deleting active/resumable thread bindings.

    What I checked:

    Likely related people:

    • Vincent Koc: Current blame in this shallow/grafted checkout attributes the central conversation-binding and run-attempt lines to Vincent Koc, and recent verified commits touch Codex binding/session and app-server cleanup surfaces. (role: recent area contributor; confidence: medium; commits: 89a73d08c805, b4cdd9211957, 815ffb3bb2e1; files: extensions/codex/src/conversation-binding.ts, extensions/codex/src/app-server/session-binding.ts, extensions/codex/src/app-server/run-attempt.ts)
    • aliahnaf2013-max: Authored the merged PR Fix one-shot Codex app-server teardown #91767 process-teardown fix that partially addresses the app-server process portion of this issue. (role: recent partial-fix author; confidence: high; commits: 870ec6dee291; files: extensions/codex/src/app-server/run-attempt.ts, src/commands/agent-via-gateway.ts, packages/gateway-protocol/src/schema/agent.ts)
    • Peter Steinberger: Verified history includes conversation-binding hooks and Codex app-server lifecycle/helper work adjacent to the remaining cleanup policy boundary. (role: feature-history owner; confidence: high; commits: 5d0887574b44, 5a7d5c6defe5, e72447de408a; files: src/plugins/conversation-binding.ts, extensions/codex/src/app-server/run-attempt.ts, docs/plugins/codex-harness.md)
    How this review workflow works
    • 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.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    on Jun 9, 2026
  3. steipete commented on Jul 18, 2026

    @steipete
    Contributor

    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.json sidecars are no longer written at all; openclaw doctor --fix migrates 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 orphaned codex app-server processes.

    If you still see orphaned app-server processes or growing sidecar counts on a current release after doctor --fix, please open a fresh issue with ps output and the OpenClaw version; hard-killing the gateway mid-turn is tracked separately in #107721.

  4. locked as resolved and limited conversation to collaborators on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions