-
Notifications
You must be signed in to change notification settings - Fork 236
Support worktree isolation for main agent and CLI commands #452
Description
Description
Add a new feature that enables worktree isolation for the main agent session or other CLI commands, not just when sub-agents use the task tool.
For example, allow omp -p or interactive mode to operate in an isolated worktree based on a configuration or flag.
Use Case
Currently, worktree isolation is only available for sub-agent execution via the task tool.
This limits isolation benefits to specific workflows and prevents safe multi-session experimentation or non-interactive runs from avoiding pollution of the user's working tree.
Supporting worktree isolation more broadly would allow parallel development, easier experimentation, and safer file edits without affecting the main working tree.
Area
No response
Proposed Solution
Add a CLI flag (e.g., --isolate-worktree) or a config setting that, when enabled, executes the main omp session (interactive or print mode) in an isolated worktree, using git worktree add. All file edits, tool usage, and shell commands would apply inside the worktree, and optionally merge results back after completion. Reference the existing worktree implementation for the task tool and provide an option for manual or automatic cleanup.
Alternatives Considered
Current workaround is to manually create and use a git worktree before starting omp, but this isn't integrated and not user-friendly. The task tool's isolation feature also can't be triggered for top-level agent runs, so there is no supported workflow for isolation outside tasks.