Skip to main content
Workspace isolation gives every agent its own working directory on its own branch, so agents editing the same repository never overwrite each other’s changes.

Quick Start

1

Default (No Isolation)

Every run shares the same directory — the behaviour you already have.
2

Concurrent Agents With Isolation

Give each agent its own git worktree — edits stay independent.
3

Reset or Remove

Restore a worktree to a clean state, or tear it down when the run ends.

How It Works

GitWorktreeAdapter runs real git worktree commands to provision a fresh branch and directory per run. When the directory is not a git repository, every method degrades gracefully — create and path return the original directory, and reset and remove do nothing.

Choosing an Adapter

Both adapters share the same interface, so you can swap them without changing your code. GitWorktreeAdapter is always safe — if the directory is not a git repo it falls back to NoIsolationAdapter behaviour automatically.

Configuration Options

GitWorktreeAdapter accepts three options.
The available attribute is True only when root is inside a git repository and git is on the PATH. NoIsolationAdapter accepts a single root option (str | Path | None, default Path.cwd()) that it returns from create and path.

Common Patterns

Give parallel sub-agents their own worktrees.
Reuse the same worktree for a named agent — create is idempotent.
Clean up when the run finishes.

Best Practices

It degrades gracefully outside git repos, so you can always reach for it. No need to detect git yourself — available reports the state and non-git directories simply fall back to shared behaviour.
Names are hashed into collision-resistant slugs, so "agent one" and "agent-one" never share a worktree. Stable names keep create idempotent across retries.
Each worktree lives under .praisonai/worktrees/. Call remove() on completion to stop that directory from growing over long-running sessions.
git worktree was introduced in git 2.5. On older git or non-git directories, isolation is unavailable and the adapter falls back to the shared directory.

Multi-Agent Context Safety

Isolate per-agent runtime and resolver state — the context half of concurrency.

Code & Workspace Access

Contain file operations to a workspace with read/write access controls.