EveryDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/mattpocock/sandcastle/llms.txt
Use this file to discover all available pages before exploring further.
run() call has a branch strategy that controls where the agent’s commits end up. Sandcastle supports three strategies — head, merge-to-head, and branch — and each sandbox provider has a default. Choosing the right strategy depends on whether you want commits applied directly to your working directory, merged back after the run, or kept on a named branch.
The three strategies
head
The agent writes directly to the host working directory. There is no worktree, no branch indirection — the agent edits files in place, and any commits land on the branch you are currently on.head is the default for bind-mount sandbox providers (Docker, Podman). It is the simplest strategy and requires no git branching overhead.
merge-to-head
Sandcastle creates a temporary branch in a git worktree. The agent works on the temp branch, and when the run completes, Sandcastle merges the temp branch back into your current HEAD branch. The temporary branch is deleted after the merge.merge-to-head is the default for isolated sandbox providers. It is also a good choice for bind-mount providers when you want the agent to work in isolation and have its changes merged back automatically.
branch
Commits land on an explicitly named branch in a git worktree. The branch is created if it does not exist, and it is not merged anywhere automatically — the commits stay there permanently.branch strategy when you want to review the agent’s work before merging, run multiple parallel agents on separate branches, or drive a PR workflow.
Setting the branch strategy
PassbranchStrategy as an option on run():
branchStrategy, the provider’s default applies:
| Provider type | Default strategy |
|---|---|
| Bind-mount (Docker, Podman) | head |
| Isolated (Vercel) | merge-to-head |
Source branch and target branch
When you usemerge-to-head or branch, Sandcastle tracks two branches:
- Source branch — the branch the agent works on. For
branch, this is the name you provide. Formerge-to-head, it is a Sandcastle-generated temporary branch. - Target branch — the host’s active branch at
run()time. Formerge-to-head, this is the branch Sandcastle merges back into.
Worktree location
When usingmerge-to-head or branch, Sandcastle creates a git worktree on the host at:
Choosing a strategy
head
Use when you want changes applied directly to your working directory and you are using a bind-mount provider. Fastest and simplest.
merge-to-head
Use when you want the agent to work in isolation and have its changes merged back to your current branch automatically. The default for isolated providers.
branch
Use when you want to keep agent commits on a named branch for review, or when running parallel agents on separate branches.
head + isolated provider
Not supported. Isolated providers cannot write directly to the host filesystem. Use
merge-to-head or branch instead.