opencode run --fork/--continue --dir <path> fails to create sessions #105

Closed
opened 2026-04-02 08:14:41 +02:00 by shoko · 0 comments
Owner

Bug Description

Running kugetsu start or kugetsu continue fails because opencode run --fork --dir <path> does NOT create a session. The command runs but the session is never registered in opencode session list. No error is shown — it silently fails.

Same issue with (cd "$worktree" && opencode run --fork ...) in a subshell.

opencode run --continue --session <id> --dir <path> also fails to work properly.

Reproduction

# Test A: --dir with --fork (FAILS - no session created)
opencode run "test" --fork --session <base-session> --dir /tmp/test 2>&1 &
# Session count stays the same

# Test B: --fork without --dir (WORKS)
opencode run "test" --fork --session <base-session> 2>&1 &
# Session count increases

# Test C: (cd && --fork) in subshell (FAILS)
bash -c "cd /tmp && opencode run \"test\" --fork --session <base-session>" 2>&1 &
# Session count stays the same

Root Cause

The --dir flag breaks session creation for --fork and --continue. When kugetsu uses --dir, the command executes but the session is never registered.

Workaround Applied

Removed --dir from opencode run --fork and opencode run --continue. Session creation now works but worktree directory isolation is lost — agents run from opencode default directory.

Impact

  • Sessions created but worktree isolation lost
  • Agents may operate in wrong directory context
  • Affects kugetsu start, kugetsu continue, and any tool using --dir with --fork/--continue
## Bug Description Running `kugetsu start` or `kugetsu continue` fails because `opencode run --fork --dir <path>` does NOT create a session. The command runs but the session is never registered in `opencode session list`. No error is shown — it silently fails. Same issue with `(cd "$worktree" && opencode run --fork ...)` in a subshell. `opencode run --continue --session <id> --dir <path>` also fails to work properly. ## Reproduction ```bash # Test A: --dir with --fork (FAILS - no session created) opencode run "test" --fork --session <base-session> --dir /tmp/test 2>&1 & # Session count stays the same # Test B: --fork without --dir (WORKS) opencode run "test" --fork --session <base-session> 2>&1 & # Session count increases # Test C: (cd && --fork) in subshell (FAILS) bash -c "cd /tmp && opencode run \"test\" --fork --session <base-session>" 2>&1 & # Session count stays the same ``` ## Root Cause The `--dir` flag breaks session creation for `--fork` and `--continue`. When kugetsu uses `--dir`, the command executes but the session is never registered. ## Workaround Applied Removed `--dir` from `opencode run --fork` and `opencode run --continue`. Session creation now works but worktree directory isolation is lost — agents run from opencode default directory. ## Impact - Sessions created but worktree isolation lost - Agents may operate in wrong directory context - Affects `kugetsu start`, `kugetsu continue`, and any tool using `--dir` with `--fork`/`--continue`
shoko closed this issue 2026-04-02 10:29:33 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/kugetsu#105