AI Factory
FA-03
Isolate agent work
What you'll produce: Isolation checklist
Definition
Isolating agent work means giving each worker its own copy of the code, a limited set of files, credentials, and network destinations, and a cap on time and spend, so that an error or a hijacked instruction cannot reach other work or production. The isolation checklist records those limits for each lane and how each one is enforced.
TL;DR
- Give every worker its own checkout. Parallel edits in one working copy collide.
- Enforce limits with rules the agent cannot argue with, such as deny rules, sandboxes, and branch protection. Instructions in a prompt are requests.
- Never give one agent private data, untrusted content, and a way to send data out at the same time.
- Cap time and spend per task, and route shared writes through one gatekeeper.
- Size the isolation to the risk. A docs fix needs a worktree. Running untrusted code needs a sandbox.
Why isolation comes before speed
An agent that can run for an hour without supervision can also be wrong for an hour without supervision. Isolation decides how far that hour can spread.
We have a near-miss on record. One of our agents had permission to write files, and one night, six hours into a run, it built a file path from another agent's output. The path pointed at a production directory. The agent did not know the difference and neither did the permission system. An approval gate on writes caught it. The lesson was that "has permission" and "should do this now" are different questions, and only the first one was being checked.
Anthropic's guidance on agents makes the general point: autonomy brings higher cost and the chance of compounding errors, so test in sandboxed environments with guardrails. A factory runs many agents at once, so it needs that advice applied per lane, in writing.
Four boundaries to draw
| Boundary |
What it stops |
Typical mechanism |
| Workspace |
Workers overwriting each other |
A checkout and branch per task |
| Reach |
Access to files, secrets, and hosts the task does not need |
Deny rules, sandbox, scoped credentials |
| Shared state |
Conflicting or stale writes to memory, data, and drives |
One gatekeeper path for writes |
| Budget |
A task that never stops |
Caps on turns, time, and spend |
The checklist is these four boundaries, answered lane by lane, with a column for how each limit is enforced and another for how it was tested.
How to do it well
One task, one checkout. Claude Code's guidance for parallel sessions is to give each its own checkout so edits cannot collide, and it can start a session in a new git worktree for that purpose. Simon Willison describes getting the same effect with a fresh clone in a temporary folder. The mechanism matters less than the rule: no two workers share a working copy.
Remember what a worktree does not cover. It separates edits. It does not confine the shell. Ignored files such as local environment settings are not copied into a new worktree by default, which is usually what you want for secrets, and a reason to decide on purpose which settings a worker receives.
Enforce, then explain. A prompt can say "do not push." A deny rule, a hook, or branch protection makes it true. Anthropic's guidance is direct about this: a rule with no exceptions belongs in a mechanism that holds in every permission mode, because a sentence in the conversation can be lost. Use the prompt to tell the worker why the fence is there.
Break the trifecta. Mark every lane for three things: private data, untrusted content, outbound communication. Any lane with all three can be steered by whatever it reads. A research lane that reads the open web should not hold customer data. A lane that holds customer data should not be able to post to arbitrary hosts. Willison's warning is that filters sold as guardrails do not catch every attack, so the reliable fix is to remove a capability.
Run risky code somewhere else. For work that executes untrusted code, put the execution inside a sandbox while the agent stays outside it. The pattern Willison documents adds an allow-list for outbound hosts and a way to make authenticated calls without handing the agent the secret.
Gate shared writes. When we grew to 17 agents, the first thing to break was memory: several agents wrote different things about the same topic and others read stale versions. We routed every knowledge write through one gatekeeper that checks role, timestamps the change, and commits it with the agent's name. The same idea applies to databases and shared drives.
Cap the run. Give each task a limit on turns, time, or spend, and say what happens at the limit. The right behaviour is to stop and report.
A worked example
This example is fictional. A marketing-technology team runs three lanes on one repository: a research lane that reads competitor pages, a build lane that edits the site, and a data lane that queries the customer warehouse.
Their reach table shows a problem. All three lanes run under one developer's credentials, so the research lane can read the warehouse and call any host. It reads untrusted pages all day. That is the trifecta in one lane.
Their checklist changes four things. Each lane gets its own worktree and branch. The research lane loses the warehouse credential and writes its notes to a folder the build lane reads as data. The data lane loses general network access and keeps one allowed host. Pushes to main are denied for every lane, and a named engineer approves merges. They test the fence by asking the research lane to read a warehouse table. The call fails, and the failure goes into the checklist as evidence.
Common failure modes
- Isolation by instruction. The limit exists only as a sentence the model may or may not still have in context.
- Shared credentials. Every lane runs as the same person, so every lane has that person's reach.
- Permission by convenience. In our 17-agent deployment, early tool scopes were set by what was easy to wire up. We now split tool access by the risk of the action.
- Orphaned workspaces. Worktrees and sandboxes pile up holding half-finished work that nobody remembers.
- A gate on everything. Review at every step slows the system until people stop using it. Put gates where actions cannot be undone.
How it connects to the other pillars
The actions that need a person come from the review-gate map in the AI Product Management pillar. Isolation is how the factory makes those gates real. If the map says a person approves customer-visible changes, the deny rule is what stops an agent from skipping the queue.
From the AI Development pillar, tool contracts define what each tool can do. Isolation decides which lane gets which tool. In this pillar, the work order states the fence, isolation enforces it, and the verification ladder checks the work that comes out.
Run it yourself
Time: ~90 min
- Inventory what each lane can reach — You need: The operating model with its worker lanes, and the credentials and tools each lane holds today. You get: A reach table per lane covering files, secrets, network, shared systems, and spend. Record what the lane can reach, not what you intend it to use. The gap between the two is the risk.
- Give each worker its own workspace — You need: The repository and a way to create separate checkouts, such as git worktrees, clones, or containers. You get: One working copy and one branch per task, with a rule for cleanup.
- Fence files and actions — You need: The scope section of the work order. You get: Deny rules or hooks for protected paths and forbidden actions such as push, deploy, and edits to secrets. Put never-rules in mechanisms that hold in every mode. A sentence in the prompt can be lost when context is compacted.
- Break the lethal trifecta — You need: The reach table, with each lane marked for private data, untrusted content, and outbound communication. You get: A change to every lane that holds all three, so that it holds two at most.
- Cap budgets and shared writes — You need: A spend and time limit per task, and a list of shared state such as memory stores, databases, and drives. You get: Per-task caps, and one gatekeeper path for writes to anything shared.
- Test the fence — You need: A harmless forbidden action for each lane, for example writing to a protected folder. You get: Evidence that each block works, attached to the checklist.
Do it with AI
You are helping me write an isolation checklist for agent workers. Work through one lane at a time and ask me for anything you do not know. Do not assume a limit is enforced unless I tell you how.
Context: repository or system [NAME]; worker lanes and what each does [LANES]; tools, credentials, and connectors each lane holds [REACH]; other agents or people working at the same time [NEIGHBOURS]; actions that cannot be undone [IRREVERSIBLE ACTIONS].
For each lane, fill in this checklist as a table with the columns item, limit, how it is enforced, how it was tested:
1. Workspace: own checkout or container, own branch, cleanup rule.
2. Files: paths it owns, paths that are read-only, paths that are denied.
3. Actions: commit, push, deploy, delete, and external sends, each allowed, gated, or denied.
4. Credentials: which secrets it can read, and whether a narrower one exists.
5. Network: destinations allowed, and whether outbound access is needed at all.
6. Untrusted content: what it reads that an outsider could have written.
7. Shared state: memory, databases, and drives it can write to, and through which gatekeeper.
8. Budget: caps on time, turns, and spend, and what happens at the cap.
9. Exit: where the result goes and who approves the merge.
Then list every lane that combines private data, untrusted content, and outbound communication, and propose the smallest change that removes one of the three. Mark every limit that relies only on a prompt instruction as NOT ENFORCED.
Chain it
- Reach auditor — Reads the lane definitions, tool configs, and credentials and builds the reach table; The operating model, agent configuration files, and the list of connectors → A reach table per lane with trifecta flags
- Checklist drafter — Proposes a limit and an enforcement mechanism for every checklist line; The reach table and the work-order scope sections → A draft isolation checklist per lane; gate: The security owner approves any lane that keeps access to secrets or production
- Fence tester — Attempts one harmless forbidden action per lane inside a disposable workspace and records the result; The approved checklist → Test evidence for each block, and a list of limits that failed
- Janitor — Finds stale worktrees, branches, and sandboxes that hold no work and proposes removal; The list of workspaces and their last activity → A cleanup list; gate: A person confirms before anything with uncommitted work is removed
How AI changes this
Automate
- Creating a fresh checkout and branch for every task
- Building the reach table from configuration files
- Testing that each deny rule and sandbox limit blocks what it should
- Cleaning up workspaces that hold no work
Keep human
- Deciding which lanes may hold secrets or reach production
- Approving any exception to a deny rule
- Choosing which of the three trifecta capabilities a lane gives up
- Approving merges and anything else that cannot be undone
Stage
- Entry: Two or more agents working at once, or one agent with access to anything you cannot easily undo.
- Exit: A checklist with every line answered for each lane, and one test showing a forbidden action is blocked.
FAQ
Is a git worktree enough isolation?
For edit collisions, yes. Each worktree is a separate checkout on its own branch, so two workers cannot overwrite each other's files. It does nothing about what the agent's shell can reach. A worker in a worktree can still read your home folder, use your credentials, and call the network. For that you need permission rules, a sandbox, or a container.
What is the lethal trifecta?
Simon Willison's name for three capabilities that are dangerous together. They are access to private data, exposure to content an attacker could have written, and a way to send data out. A model follows instructions in whatever it reads, so an agent holding all three can be told by a web page or an email to leak what it can see. Remove one of the three from every lane.
Can I tell the agent in the prompt what not to touch?
Say it, and also enforce it. A prompt instruction is read by a model and can be dropped when the conversation is compacted. Anthropic's Claude Code guidance puts rules with no exceptions into deny rules, hooks, and the sandbox, because those hold in every mode. Treat the prompt as the explanation and the mechanism as the limit.
Does isolation slow the work down?
A little. In our own approval system, routine gates added about 30 seconds and complex ones about five minutes, and a ten-minute workflow became a fifteen-minute one. In exchange the team let agents run longer between reviews. Isolation is what makes it reasonable to stop watching.
Sources
Related