loc bengaluru, ist | local --:-- srijanshukla18@gmail.com →
[post]/tech/territorial-agent-orchestration

stopping parallel sub-agents from stepping on each other (TAO)

/ 3 min read· ai

A prompt rule for running parallel agents without conflicts: the coordinator owns the shared work, sub-agents only get isolated slices.

If you spawn 5 sub-agents in parallel on the same codebase without strict boundaries, you know what happens next: Agent A edits types.ts, Agent B edits types.ts differently, Agent C imports a function signature that no longer exists, and you spend more time untangling merge conflicts than if you had just run one agent sequentially.

I started using one simple prompt rule to stop parallel agents from stepping on each other. I call it TAO (Territorial Agent Orchestration).

The rule

Before the main agent is allowed to spawn any sub-agents, it has to split the files/modules into two buckets:

  1. Isolated slices (files that only one task touches) -> spawn parallel sub-agents for these.
  2. Shared territory (shared types, config, index files, final wiring) -> the main coordinator agent must keep this for itself.

If two tasks touch the same files, you are not allowed to put them in separate parallel sub-agents. Either the coordinator does them, or a single sub-agent gets both.

Example from a real run

I gave the main agent a multi-module build where everything depended on a shared set of interfaces and an integration layer.

Because of the TAO prompt rule, instead of blindly spawning sub-agents that all try to edit the shared types at once, the main agent:

  1. Wrote and locked the shared types itself first
  2. Spawned 7 parallel sub-agents, each restricted to its own isolated module folder (Slice A through Slice G)
  3. Waited for all 7 to finish, then wired up the final entrypoint and integration tests itself
7 task agents launched
├─ Agent 1: Slice A
├─ Agent 2: Slice B
├─ Agent 3: Slice C
├─ Agent 4: Slice D
├─ Agent 5: Slice E
├─ Agent 6: Slice F
└─ Agent 7: Slice G

Zero file conflicts across all 7 agents coz their write paths literally did not overlap.

The prompt snippet

If your agent harness supports sub-agents (Claude Code, Codex, Pi, Hermes, etc.), drop this into your system prompt or AGENTS.md:

You can spawn sub-agents for parallel work. Before spawning:

1. Map what files/modules each task touches
2. Identify overlapping territories
3. For isolated slices: spawn a sub-agent with exclusive write ownership of those files
4. For overlapping/shared work: handle it yourself
5. You own all shared types, configs, and integration points

Rule: If any two tasks touch the same files, do not spawn
separate parallel agents for them. Either handle both yourself,
or assign both to a single agent.

Sub-agents can read shared files, they just aren’t allowed to edit them. That one constraint eliminates 90% of multi-agent chaos.