openai / openai/codex-plugin-cc
[BUG] codex:codex-rescue hangs in worktrees when run_in_background is used
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Summary
codex:codex-rescue tasks hang indefinitely when dispatched with isolation: "worktree" and the rescue agent uses run_in_background: true on the Bash call. The worktree is cleaned up before Codex finishes, leaving Codex running in a deleted directory.
Root Cause
- Rescue agent calls
codex-companion.mjs task --writewithrun_in_background: true - Bash returns immediately ("Command running in background...")
- Rescue agent returns "Codex task dispatched in background" and exits
- CC sees agent returned with no file changes → deletes the worktree
- Codex is now running in a deleted directory → hangs at "Turn started"
The rescue agent uses run_in_background in two cases:
- Explicitly:
--backgroundflag in the task text is interpreted asrun_in_background: true - Implicitly: For large prompts with long timeouts, Claude sometimes independently decides to background the call
Repro
# SUCCEEDS — rescue agent waits for Codex to complete:
Agent(subagent_type="codex:codex-rescue", isolation="worktree",
prompt="Create foo.txt with content hello")
# FAILS — rescue agent backgrounds, worktree cleaned before Codex finishes:
Agent(subagent_type="codex:codex-rescue", isolation="worktree",
prompt="Create foo.txt with content hello. --background")
Parallel dispatch without --background works fine — three concurrent worktree tasks all succeed. The issue is purely about early worktree cleanup from backgrounding.
Suggested Fix
In codex-cli-runtime SKILL.md, change the --background handling from:
- If the forwarded request includes `--background` or `--wait`, treat that as Claude-side
execution control only. Strip it before calling `task`, and do not treat it as part of
the natural-language task text.
To:
- If the forwarded request includes `--background` or `--wait`, strip it before calling
`task`. Do NOT set `run_in_background` on the Bash call. The rescue agent MUST wait for
Codex to complete — backgrounding causes the parent worktree to be cleaned up before
Codex finishes, silently orphaning the task.
Impact
Any codex:codex-rescue dispatched with isolation: "worktree" where the rescue agent backgrounds the Bash call will silently fail. No error, no timeout — just an indefinite hang at "Turn started" with Codex working in a deleted directory.
Environment
- Claude Code 2.1.89
- codex-plugin-cc (marketplace install)
- macOS Darwin 25.2.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with codex-cli-runtime SKILL.md and inspect the rescue agent's handling of --background and --wait before the codex-companion.mjs task --write call. Verify the worktree reproduction with isolation set to worktree, then confirm the rescue agent waits for Codex and that the task completes without leaving Codex in a deleted directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100