Phase 14 · Lesson 45 of 54

Delegate Agent Work with Isolation and Merge Contracts

Parallel agents save wall time only when the work is independent. Otherwise they convert one clear task into a coordination problem with a faster failure rate.

Lesson 45 of 54Learn + Build~70 minutesPython (stdlib)

Before this: Lessons 39 and 44 of Phase 14

On this page

Learning Objectives

  • Decide whether delegation is justified by real independence.
  • Give each worker exclusive file ownership and explicit proof.
  • Compute execution waves from dependencies.
  • Design a merge contract for combining agent work safely.

The Parallelism Test

Do not delegate because more agents are available. Delegate when at least one of these is true:

  • two investigations can answer different unknowns independently;
  • two implementations own disjoint files and contracts;
  • a reviewer can inspect a completed artifact without changing it;
  • a slow external check can run while local work continues.

Keep work serial when agents need the same files, the same unresolved decision, or the same mutable environment.

A Work Unit Is a Contract

Each delegated unit needs:

Field Meaning
Goal One observable result
Owner One accountable worker
Paths Exclusive write ownership
Dependencies Completed units required before starting
Proof Exact evidence returned to the integrator
Handoff Files changed, decisions made, remaining risk

“Handle the backend” is not a work unit. “Implement the duplicate check in app/accounts.py and prove it with the focused account test” is.

Isolation Has Three Layers

  1. Filesystem isolation: separate worktrees or sandboxes prevent accidental shared edits.
  2. Ownership isolation: contracts prevent two workers from intentionally editing the same path.
  3. State isolation: separate logs and outputs prevent one worker from overwriting another worker’s evidence.

Filesystem isolation does not solve ownership. Two clean worktrees can still produce conflicting designs. The merge contract must resolve shared interfaces before work begins.

Diagram (opens full size)

The Integrator Does Not Rebuild the Work

The integrator should:

  1. confirm each handoff matches its assigned scope;
  2. read the proof output, not just the worker’s summary;
  3. combine changes in dependency order;
  4. run the full cross-unit gate;
  5. reject hidden scope expansion;
  6. record conflicts as new decisions, not silent edits.

If integration requires rewriting most of a worker’s result, the original decomposition was wrong.

Human and Agent Roles

Delegation does not remove human judgment. The human still owns choices that change public behavior, risk, authority, or irreversible cost. Agents can own bounded investigation, implementation, verification, and review.

This is calibrated autonomy: the system grants freedom where evidence and rollback are strong, and requires a checkpoint where consequence is high.

Build It

The lab checks path overlap, validates dependencies, computes safe execution waves, and writes outputs/delegation-plan.json.

Run:

python3 code/main.py
python3 -m unittest discover code/tests -v

Change the docs unit to own app/. The plan should block because that parent path overlaps the API unit.

Exercises

  1. Decompose a real change into two independent work units and one integrator.
  2. Find a proposed parallel split that only looks independent. State the shared decision.
  3. Add a read-only research worker whose output is a fact table.
  4. Add a merge gate that checks the final changed-file set against all unit contracts.
  5. Define a cancellation rule for a worker whose dependency becomes invalid.

Further Reading

What You Keep

Keep outputs/delegation-plan.json. It records why the split is safe, who owns each path, and what proof integration must receive.

Check yourself

Quick quiz

  1. When is parallel delegation justified?

    1. When work has real independence in decisions, paths, or waiting time
    2. For every task over ten minutes
    3. Whenever more agents are available
    4. Only for documentation
    Show the answer

    A. When work has real independence in decisions, paths, or waiting time Parallelism helps only when units can progress without shared mutable decisions or ownership.

  2. Which guarantee does filesystem isolation not provide?

    1. Exclusive design and path ownership
    2. Independent command execution
    3. Recoverable branches
    4. Separate directories
    Show the answer

    A. Exclusive design and path ownership Two isolated worktrees can still implement conflicting designs.

  3. Why must each work unit name proof?

    1. To avoid a handoff
    2. To increase concurrency
    3. So the integrator receives reproducible evidence
    4. So the worker can claim success
    Show the answer

    C. So the integrator receives reproducible evidence The integrator must verify results, not trust summaries.

  4. What should happen when two units own overlapping paths?

    1. Let the last worker win
    2. Merge without review
    3. Run them faster
    4. Block and redesign the split
    Show the answer

    D. Block and redesign the split Overlapping write ownership creates avoidable conflict and ambiguity.

  5. What is calibrated autonomy?

    1. Manual work only
    2. Freedom where evidence and rollback are strong, checkpoints where consequence is high
    3. Full automation
    4. Random approvals
    Show the answer

    B. Freedom where evidence and rollback are strong, checkpoints where consequence is high Authority should follow consequence and reversibility.

  6. What is the integrator's final responsibility?

    1. Delete handoffs
    2. Choose a larger model
    3. Rewrite every unit
    4. Run the full cross-unit verification gate and enforce scope
    Show the answer

    D. Run the full cross-unit verification gate and enforce scope Unit proof does not replace end-to-end integration evidence.

Questions people ask

When does it make sense to run AI agents in parallel?

When tasks do not share files, decisions or environments, such as researching two separate questions or building two unrelated parts. If they need the same files or wait on the same decision, run them one after another.

How do you merge work from multiple AI agents?

Give each agent exclusive ownership of certain files, a defined goal and required proof. Combine results in an order based on dependencies, and run tests after each merge to catch conflicts early.

Next lessonTurn Every Agent Correction into a System ImprovementPrevious: Build an Evidence-Backed Execution Plan

Lessons from AI Engineering from Scratch by Rohit Ghumare and contributors, MIT license. Notes for owners by Lozo. License

Next step

Rather have it built for you?

Reading is optional. Tell me what's stuck and I'll build it into the business you already run.

  • A real conversation, not a pitch
  • You keep your accounts
  • Nothing sends without your yes