Workdir and Worktree Strategy
Choosing the right run location is the biggest lever for stable agent behavior.
Two Modes
use_existing: run directly in an existing directorycreate_worktree: create an isolated worktree under your configured root
For remote execution, the selected Agent Node may override the effective
default root with its own node-specific Default worktree root.
How to Choose
Use use_existing when:
- You need direct access to a long-lived local workspace
- You intentionally want local uncommitted state to be visible
Use create_worktree when:
- You want reproducible isolated runs
- Multiple tasks may run in parallel on the same repository
- You need safer cleanup boundaries after task completion
Naming Convention Suggestion
Use predictable names for easier operations:
- Agent name:
<repo>-<goal>-<date> - Worktree path suffix:
<ticket-or-topic>-<short-hash>
Example:
agent:agenthub-docs-2026-02-15worktree:docs-user-guide-5db671b0
Safe Path Constraints
All run paths must be under configured safe_paths.
If creation fails with path-related errors:
- Confirm base path is allowed
- Confirm the selected remote node has a valid default root if you are leaving
Workdirblank increate_worktreemode - Avoid symlink-heavy paths at first
- Retry with a shorter explicit directory path
Cleanup Practice
For create_worktree mode:
- Keep each task focused
- Delete stale task agents regularly
- Archive or merge useful changes before cleanup