Summary
When opencode:opencode-rescue is dispatched with isolation: "worktree" and the rescue subagent runs its single Bash call with run_in_background: true, the subagent returns immediately. Claude Code sees the subagent exit with no file changes and deletes the worktree — but OpenCode is still running inside the now-deleted directory and hangs indefinitely.
Two paths reach this state today:
- Explicit: the user includes
--background in the rescue request. plugins/opencode/skills/opencode-runtime/SKILL.md:26 and plugins/opencode/agents/opencode-rescue.md:23 treat --background as "Claude-side execution control" without explicitly forbidding run_in_background: true on the Bash call.
- Implicit: for long prompts, Claude Code sometimes decides to background a slow Bash call on its own.
Suggested fix
Update plugins/opencode/skills/opencode-runtime/SKILL.md and plugins/opencode/agents/opencode-rescue.md to say: strip --background before calling task, and do not set run_in_background on the Bash call. The rescue subagent must wait for OpenCode to complete, because backgrounding in a worktree causes silent orphaning.
Rescue uses opencode-companion task --background for the long-running path already (see handleTask in opencode-companion.mjs:325-342), which spawns a detached worker. That mechanism is the correct way to background OpenCode, not run_in_background on Bash.
Upstream reference
Derived from openai/codex-plugin-cc#198.
Summary
When
opencode:opencode-rescueis dispatched withisolation: "worktree"and the rescue subagent runs its singleBashcall withrun_in_background: true, the subagent returns immediately. Claude Code sees the subagent exit with no file changes and deletes the worktree — but OpenCode is still running inside the now-deleted directory and hangs indefinitely.Two paths reach this state today:
--backgroundin the rescue request.plugins/opencode/skills/opencode-runtime/SKILL.md:26andplugins/opencode/agents/opencode-rescue.md:23treat--backgroundas "Claude-side execution control" without explicitly forbiddingrun_in_background: trueon the Bash call.Suggested fix
Update
plugins/opencode/skills/opencode-runtime/SKILL.mdandplugins/opencode/agents/opencode-rescue.mdto say: strip--backgroundbefore callingtask, and do not setrun_in_backgroundon the Bash call. The rescue subagent must wait for OpenCode to complete, because backgrounding in a worktree causes silent orphaning.Rescue uses
opencode-companion task --backgroundfor the long-running path already (seehandleTaskinopencode-companion.mjs:325-342), which spawns a detached worker. That mechanism is the correct way to background OpenCode, notrun_in_backgroundon Bash.Upstream reference
Derived from openai/codex-plugin-cc#198.