Worker Coordination: Partial Result Passing Between Parallel Agents
The standard parallel agent pattern (subagents or teams) assumes workers have non-overlapping scope and only need to report completion back to the coordinator. When workers need each other’s partial outputs mid-task, this assumption breaks. First question before reaching for a coordination pattern: is the decomposition wrong? “Worker A needs a partial result from Worker B” is often a sign that the work was not truly parallel. Restructure first:- Can the shared dependency be computed before workers are spawned? → contract-first
- Does B’s output simply feed into A? → pipeline (sequential, not parallel)
- Is the dependency bidirectional and emergent? → blackboard
Pattern 1: Contract-First (Pre-coordination)
Define all interfaces, schemas, and API contracts before spawning workers. Workers operate on the contract file, not on each other’s live output.Pattern 2: Pipeline (Sequential Fan-Out)
If A needs B’s output but B doesn’t need A’s — it’s not parallel, it’s sequential. Make it explicit.Pattern 3: Filesystem Blackboard
Shared directory that workers read and write intermediates to. Workers poll for dependencies before proceeding.- Coordinator seeds the blackboard with initial state before spawning workers
- Each worker writes its partial outputs to its own path at defined checkpoints
- Workers that need a sibling’s output poll with a bounded retry (e.g. 3× with 5s delay)
- If dependency doesn’t arrive within budget → escalate to coordinator, don’t hang
Pattern 4: Actor Mailbox
Workers send typed messages to each other’s mailboxes. The receiver processes messages when it’s ready, giving natural back-pressure.Decision Table
Common Failure Modes
Silent dependency failure: Worker B crashes or stalls; Worker A polls forever. Fix: always bound retries, always escalate to coordinator. Partial write races: Worker A reads Worker B’s partial output mid-write. Fix: workers write to a temp path then atomically rename; readers only consume complete files (use.json.tmp → .json rename pattern).
Scope bleed: Workers modify each other’s files instead of reading the blackboard path. Fix: strict file ownership — each worker only writes to its own path.
Related Pages
- Agent Teams — team architecture; the standard pattern this extends
- Agent Subagents — subagent isolation; when partial results indicate wrong decomposition
- Actor Model — mailbox semantics, message-passing primitives (Orleans/Akka/Erlang)
- Ralph Loop — filesystem state between context windows; same durability principle
- Worktree Isolation — how workers get filesystem isolation while sharing the blackboard
- Agent Primitive Selection — decision tree for which primitive to reach for