anomalyco / anomalyco/opencode
opencode run --session --fork stalls with zero output when --dir changes to a Git worktree
@rekram1-node is already working on this.
Since Aug 30, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
opencode run --session <id> --fork completes when the child keeps the parent
session's directory, but can stall before emitting its first JSON event when
--dir changes to another Git worktree of the same repository.
The stalled process produces zero stdout and zero stderr until it is killed by
an external timeout. The reproduction is sequential: no two opencode run
processes overlap.
Environment
- macOS 14.6.1 (23G93), Intel x86_64
- Reproduced with OpenCode 1.17.11 and 1.18.25
opencode run --format json- Reproduced without a filesystem sandbox, permission overlay, or wrapper
Minimal reproduction
Start with a Git repository at [REPO_A] and create a second worktree:
git -C [REPO_A] worktree add --detach [REPO_B] HEAD
Create two equivalent one-turn parent sessions in [REPO_A], recording their
session IDs as [SAME_DIR_PARENT] and [CROSS_DIR_PARENT]. Use each parent only
once in the controls below.
Same-directory control — completes and emits step_start, text, and
step_finish:
printf '%s\n' 'Reply exactly OK. Do not use tools.' |
opencode run --format json --dir [REPO_A] \
--session [SAME_DIR_PARENT] --fork --model [PROVIDER/MODEL]
Cross-directory case — stalls with zero stdout and stderr:
printf '%s\n' 'Reply exactly OK. Do not use tools.' |
opencode run --format json --dir [REPO_B] \
--session [CROSS_DIR_PARENT] --fork --model [PROVIDER/MODEL]
An external 25–30 second timeout is needed to terminate the second command.
Observed controls
- Fresh sessions complete in both
/tmpand the source Git repository. - A one-shot fork that keeps the parent directory completes.
- A one-shot fork from an equivalent parent into a different worktree stalls
before its first event. - The cross-directory stall reproduces on both 1.17.11 and 1.18.25.
- Adding or removing the caller's permission overlay does not change the result.
- Adding or removing macOS
sandbox-execdoes not change the result. - Exporting/importing the parent with the worktree directory and resuming the
imported session also stalled in the observed environment.
Expected behavior
The fork should preserve the parent context and launch in the requested
directory, or fail quickly with an actionable error if changing the child
directory is unsupported. It should not remain alive indefinitely with no
stdout or stderr.
Related issues
#31964reports changed-cwd session state and permission routing problems
through ACP.#35870reports intermittent headless startup hangs, especially for fresh
directories.
This reproduction is narrower: opencode run --session ... --fork, sequential
processes, same Git repository, and same-directory versus sibling-worktree
controls.
Contributor guide
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.
Assessment
This issue has not been assessed yet.