Multi-agent coordination and shared state
medium 7 minA multi-agent system distributes work across contexts or roles and then reconciles results.
Two reporters, one clipping, one source.
Two reporters hand an editor copies of the same clipping. The editor traces both reports to the same original before deciding what is corroborated.
Video lesson · Chapter 1 of 4
Two workers repeat one draft
Theory
Read or listen first. About 2 min.
What it is
A multi-agent system distributes work across contexts or roles and then reconciles results. The coordination protocol decides who owns the next action, what evidence workers must return and how a conflict is resolved.
Why it exists
A panel of workers can amplify one mistaken source. Evaluate independent evidence, communication overhead and the final state against a single-agent baseline, using the same task set and resource accounting.
Two workers cite different versions of one policy
Inside this chapter
Chapter sources- Why Multi-Agent?
- Multiple workers are useful when subtasks benefit from separate contexts or independent evidence. Coordination introduces messages, latency and extra tokens. Compare with one well-equipped agent on the same workload. Counting workers says little about whether the final answer is more reliable.
Splitting work helps when a single context would be overloaded or when you genuinely need independent evidence. The fair test is one well-equipped agent with the same total budget on the same tasks. If the multi-agent version only wins because it was allowed more tokens, the gain came from budget, not structure.
Example. Give two researchers independent authorized sources and compare their combined result with one researcher allowed the same total budget.
What separate workers can buy
- Clean, separate contexts per subtask
- Independent sources checked independently
- Parallel work on unrelated parts
What they always cost
- Extra messages, tokens and latency
- A merge step that can itself be wrong
- Harder tracing across contexts
- Agent Roles
- A role is useful when it changes responsibility, context or permissions. A researcher can return evidence while a reviewer checks support and a coordinator resolves disagreements. Merely naming two identical prompts “expert” and “critic” rarely establishes independent verification.
A role earns its place when it changes what an agent sees, what it may do or what it is accountable for. Calling one prompt "expert" and an identical one "critic" adds cost without independence. Enforce the role in the tool gateway: the researcher literally cannot call publish.
Example. Let the researcher read drafts but the publisher publish only approved records. Verify permissions reflect those actual responsibilities.
Roles defined by permission, not by name
Role Can read Can write Returns Researcher sources, drafts nothing external evidence with source IDs Reviewer evidence, sources review notes supported or unsupported per claim Coordinator all worker outputs shared run state resolved answer Publisher approved records only the public page publish receipt If two roles have identical permissions and context, they are one role with two prompts. - Coordination Patterns
- A supervisor centralizes assignment, handoffs transfer ownership, and parallel workers produce independent partial results. Choose an explicit merge rule. When two workers report conflicting effective dates, the coordinator should compare original documents rather than averaging dates or counting votes.
Supervisor, handoff and parallel fan-out differ in who owns the next action. A supervisor keeps ownership and delegates; a handoff transfers ownership entirely; parallel workers each own a slice until a join. Whatever the pattern, write the merge rule down before running it, including what happens when results conflict or one worker never returns.
Example. One worker verifies pricing while another verifies dates. Join both results only when the original question requires both facts.
Parallel workers with an explicit join
If the two disagree on a fact, the coordinator compares the original documents. It never averages dates or counts votes. - Communication Between Agents
- Agent messages need typed payloads, source references, sender identity and correlation IDs. Keep observations distinct from suggestions. A worker’s summary may be wrong even when another worker repeats it. Preserve the original evidence so later stages can verify the claim.
Free-text messages between agents lose provenance at every hop. A typed envelope keeps the sender, a correlation ID tying the reply to its question, and the source IDs behind each claim. When replies arrive out of order, the correlation ID reconstructs which answered what; when a claim is challenged, the source IDs let anyone go back to the evidence instead of trusting the summary.
Example. Two concurrent lookups finish in reverse order. Use correlation IDs and source IDs to reconstruct which question each returned record answered.
JSON{ "sender": "worker-dates", "correlation_id": "q-118/dates", "type": "observation", "claim": "Policy effective from 1 April", "source_ids": ["policy-v7#s3"], "status_of_source": "approved"}A typed message: who sent it, which question it answers, whether it is an observation or a suggestion, and the original evidence. - Conflict Resolution
- Resolve conflicts by checking authority, recency, evidence and shared state versions. Define which conflicts can be resolved automatically and which require review. An older approved policy can supersede a newer draft; timestamp alone is an insufficient tie breaker.
Decide ahead of time which conflicts the system may settle alone and by which rule. Authority (approved, draft, rumour) normally outranks recency, and effective date matters more than the date a document was written. Keep the losing claim, flagged, so reviewers can see that a conflict existed and how it was settled.
Example. A newer draft contradicts an approved policy. Resolve by authority and effective date, preserving the draft as a flagged conflict.
Authority first, then effective date
Timestamp of writing is not on this chart. A newer draft does not outrank an older approved policy. - The Supervisor Pattern
- A supervisor delegates bounded subtasks, receives evidence and decides when to synthesize. Give workers explicit responsibilities and return contracts. Two workers repeating the same search do not provide independent confirmation. Track source provenance across delegations.
The supervisor's job is to split the task into bounded pieces, state what each worker must return and decide when there is enough to synthesise. Track provenance across delegations: if two workers ran the same search, their agreement is one finding, not two. Give each worker a budget so one stuck worker cannot stall the whole run.
Example. A supervisor assigns one worker to approved policies and one to draft changes. Their outputs must carry status and source IDs back to the supervisor.
Delegation with a return contract
Each worker returns status and source IDs, so the supervisor can resolve the conflict rather than pick the louder answer. - Hierarchical State
- Hierarchical state separates shared run facts from worker-local scratch state. Publish versioned results instead of allowing every worker to overwrite the global answer. A coordinator should reconcile conflicts explicitly and retain enough history to see which worker supplied each claim.
Let workers keep messy scratch state privately and publish only finished, versioned results into their own slot. The coordinator then merges with knowledge of the version each result was based on, and records which worker supplied which claim. This avoids the last-writer-wins bug where a slow worker overwrites a newer answer.
Example. Two workers produce candidate dates. Commit their findings to separate slots before applying a version-aware merge to shared state.
Workers publish to slots, the coordinator merges - 1Worker scratchlocal notes, never shared
- 2Publish to own slotslot A: 1 Apr, slot B: 15 Apr
- 3Version-aware mergecompare against state v4
- 4Shared state v5date chosen, conflict logged
No worker writes the global answer directly, so nobody's result is silently overwritten.
How it works
Step through the idea, or press Play.
First finding. Approved policy v7
Understand it
Worked example
Two workers cite different versions of one policy
- 1
Approved policy v7
The worker returns the exact section, version and approval status, not just an answer.
- 2
Draft v8
A different worker finds a newer date. Its source is a draft and cannot automatically supersede the approved text.
- 3
Use v7 and flag v8
The coordinator resolves the conflict using the authority rule. The two reports came from the same policy lineage, so they are not independent votes.
Follow the handoffs
The two findings side by side
| Finding | Source | Version | Status | Independent? |
|---|---|---|---|---|
| Research worker | refund policy, section 3 | v7 | approved | yes |
| Review worker | refund policy, section 3 | v8 | draft | same lineage as v7 |
| Resolved | v7 used, v8 flagged | v7 | approved | n/a |
Repetition is not corroboration
Summary
The whole topic in one minute.
Count original evidence and its authority. Message duplication across workers creates no additional corroboration.
A panel of workers can amplify one mistaken source. Evaluate independent evidence, communication overhead and the final state against a single-agent baseline, using the same task set and resource accounting.