All articles
11 min read
#Multi-Agent Systems#Agent Orchestration#Durable State#Failure Recovery#LLM Evals

Multi-Agent Systems: Durable Coordination Patterns

A stateful architecture for coordinating AI agents with explicit roles, durable handoffs, tool boundaries, and deterministic recovery.

On this page

Why this matters

A multi-agent system often looks deceptively simple on a diagram: one agent plans, several specialist agents perform bounded tasks, and a final agent assembles the answer. Assigning roles is the easy part. The hard part is preserving a reliable account of what happened when a tool call times out, a worker produces malformed output, or the process stops halfway through a run.

I treat a multi-agent system as a stateful workflow with model-driven decision points, not as a group conversation. That distinction changes the architecture. A conversation can be useful for exploring a problem. A production workflow needs explicit ownership, durable records, transition rules, and a recovery path that does not depend on reconstructing intent from prompt history.

The design target I use is modest: at every step, I want to answer four questions from persisted data:

  1. Which agent currently owns this work item?
  2. What input did that agent receive?
  3. Which tools did it call, and what result was recorded?
  4. Which transition is permitted next?

If I cannot answer those questions after a restart, I do not consider the coordination layer complete. This framing also keeps the boundary between agents clear. An agent may propose a decision; the orchestrator records and validates the decision before it becomes workflow state.

For a complementary view of message contracts, I use agent-to-agent communication. For an example of turning a role-based framework into an operational workflow, I use CrewAI multi-agent production patterns as related reading.

What fails when roles are only prompts

The most common early failure is implicit delegation. A coordinator prompt says that a researcher should investigate, a reviewer should check the result, and a writer should compose the response. The model may follow that sequence during a clean run, but the sequence is not an enforceable protocol. There is no durable indication that research completed, no idempotency boundary around an external call, and no authority rule for conflicting conclusions.

This produces several predictable classes of failure.

Shared context becomes a mutable scratchpad

When every agent reads and writes a single free-form transcript, important distinctions disappear. A tentative hypothesis can look identical to an accepted fact. A tool error can be summarized away by a later agent. A reviewer may receive an edited version of the researcher’s work rather than the original artifact.

I avoid using an LLM transcript as the system of record. Instead, I store structured facts, task outputs, tool receipts, and decisions as separate records. The transcript can remain useful as an input artifact, but it is not the authority for state transitions.

Agents receive overlapping authority

Two agents can both be asked to “improve the answer,” but that instruction leaves conflict resolution undefined. One might revise a source list while another changes the conclusion based on an earlier list. The result is not necessarily wrong; it is untraceable.

I assign each work item one owner at a time. Other agents may produce proposals or reviews, but only a transition handler changes the work item’s accepted state. This is less conversational than a peer swarm, but it gives me a stable place to inspect why a result changed.

Tool effects are mixed with reasoning

A model can request an action, but a request is not evidence that the action occurred. This matters for tools that write a file, send a message, create a ticket, or call an external API. Retrying an interrupted step without an idempotency key can duplicate the effect.

I separate tool_requested, tool_succeeded, and tool_failed events. The worker may reason about a result only after the orchestrator records a receipt. SQLite’s write-ahead logging documentation describes a model in which readers can continue while a writer appends changes to a WAL file; I still keep workflow transitions short and explicit rather than holding a transaction open while a model or tool runs. SQLite WAL documentation

Recovery is delegated to another model call

A weak recovery strategy asks a new coordinator instance to read the surviving transcript and infer what to do. I do not use that approach for side-effecting work. It turns an infrastructure failure into a fresh reasoning problem, and the next action can depend on context that was never persisted.

Instead, I resume from the last committed transition. A pending external action is either retried with its recorded idempotency key, reconciled against a recorded receipt, or moved to a human-review state. The model can help classify a failure, but it does not decide whether an unrecorded side effect happened.

The design I use

The design I return to has four layers: a task ledger, role contracts, tool adapters, and a transition engine. Each layer has a narrow responsibility.

1. Use a ledger, not a shared notebook

I represent a run as an append-only sequence of events plus a materialized task view. The event sequence preserves the audit trail; the task view makes scheduling inexpensive. A task has an identifier, a parent run, a current state, an owner, an input reference, and an attempt number.

Here is a compact event shape I use as a starting point:

{
  "event_id": "evt_01J9Q6K3",
  "run_id": "run_2025_03_08_001",
  "task_id": "research.sources",
  "sequence": 17,
  "type": "agent.output.accepted",
  "actor": "source_reviewer",
  "input_ref": "sha256:4bb4...",
  "output_ref": "sha256:9c3d...",
  "decision": {
    "next_state": "ready_for_writer",
    "reason_code": "sources_verified"
  },
  "recorded_at": "2025-03-08T12:00:00Z"
}

I store large prompts, retrieved documents, and tool payloads outside the event row and reference them by content hash. This keeps the state log compact while preserving the exact input available to an agent. If canonical byte-level JSON is required for hashing across independent producers, RFC 8785 specifies a JSON canonicalization scheme. RFC 8785

The important design choice is that an agent output is not automatically accepted. It begins as a proposal. A validator checks the output contract, a policy check evaluates whether the transition is allowed, and only then does the orchestrator append an acceptance event.

2. Make roles contracts, not personalities

I define a role by its accepted input, allowed tools, output schema, and transition permissions. Describing a role as “careful” or “creative” can help prompt behavior, but those traits are not the contract.

For example, a researcher may produce candidate evidence. A reviewer may accept, reject, or request more evidence. A writer may consume only accepted evidence and produce a draft. The writer cannot silently approve its own unsupported source. That restriction is enforced by the workflow, not trusted to the wording of a prompt.

I use schemas at boundaries because they make rejection explicit. JSON Schema defines vocabularies for constraining JSON instances; I apply a restricted schema subset that I can validate consistently in my runtime. JSON Schema Core, Draft 2020-12

{
  "type": "object",
  "required": ["claim", "evidence_ids", "confidence", "disposition"],
  "properties": {
    "claim": { "type": "string", "minLength": 1 },
    "evidence_ids": {
      "type": "array",
      "items": { "type": "string" },
      "minItems": 1
    },
    "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
    "disposition": {
      "type": "string",
      "enum": ["accept", "reject", "needs_more_evidence"]
    }
  },
  "additionalProperties": false
}

A schema does not establish that an answer is correct. It establishes that downstream code receives a shape it knows how to handle. I keep semantic checks separate: evidence identifiers must exist, cited artifacts must belong to the run, and a reviewer cannot approve a task outside its assignment.

3. Put tools behind recorded adapters

I give agents capabilities through adapters rather than direct credentials. Each adapter receives a request envelope containing the run identifier, task identifier, action name, idempotency key, and bounded arguments. It returns a normalized receipt or failure record.

The key operational rule is simple: tool execution is a state transition boundary. I persist the intent before dispatching the call. I persist the receipt after dispatch. If a worker stops between those operations, recovery inspects the intent and resolves the uncertainty according to the tool’s contract.

For read-only tools, I can often retry safely. For write tools, I prefer an idempotency key accepted by the destination, or I route the operation to review. I do not hide that ambiguity behind a confident model-generated status message.

4. Make the scheduler boring

I prefer a deterministic scheduler over an agent that continually negotiates task ownership. Given the current materialized state, the scheduler selects eligible tasks by explicit rules: dependencies accepted, lease expired, retry budget available, and required artifacts present.

This small transition function illustrates the shape. The actual persistence boundary sits around the transition and dispatch steps, not inside the function.

ALLOWED = {
    "queued": {"running", "cancelled"},
    "running": {"waiting_for_tool", "review", "failed"},
    "waiting_for_tool": {"running", "review", "failed"},
    "review": {"accepted", "queued", "failed"},
    "accepted": set(),
    "failed": set(),
    "cancelled": set(),
}


def transition(task, target, reason):
    if target not in ALLOWED[task["state"]]:
        raise ValueError("transition is not permitted")
    return {
        **task,
        "state": target,
        "attempt": task["attempt"] + (target == "queued"),
        "last_reason": reason,
    }

I use leases for workers, but I treat a lease as permission to attempt work, not evidence of completion. Completion is established only by a committed event carrying validated output or a tool receipt.

How I verify the coordination layer

I verify this kind of system with replayable fixtures rather than relying on an end-to-end demonstration alone. I capture a run fixture containing initial state, scheduled events, fixed model outputs, tool receipts, and expected terminal state. The purpose is not to prove that a model is universally reliable. The purpose is to check that orchestration handles known decisions and failures consistently.

My first test group covers transition legality. For every state, I test each permitted successor and a sample of prohibited successors. This catches accidental routes such as approving a draft before its evidence review completes.

My second group covers failure injection. I stop a worker after recording tool intent, after receiving a tool response, and after validating an agent proposal but before acceptance. On restart, I assert that the next action comes from the persisted state and that no prior accepted event is reinterpreted.

My third group covers role isolation. I submit outputs that contain a valid-looking task identifier from another role, references to missing artifacts, extra fields, and a request for an unauthorized tool. The expected result is a typed rejection event, not a best-effort continuation.

I also record a compact run digest: ordered event types, task-state changes, artifact hashes, and normalized tool receipts. Comparing this digest between revisions makes coordination changes visible without claiming that model text itself should be byte-identical. I reserve full-text comparisons for cases where the model response is fixed by a fixture.

What I avoid

I would not let agents share a mutable prose memory as their only coordination mechanism. It is convenient at the beginning and expensive during incident analysis.

I would not give every agent the same tool set. A role with fewer capabilities is easier for me to evaluate and recover. The coordinator should hold authority for dispatch; a specialist should receive only the capability required by its current task.

I would not treat a successful-looking final answer as evidence that the workflow worked. A run can produce acceptable text despite skipped review, duplicated tool effects, or unresolved state. I inspect the event trail and transition history separately from the final artifact.

Finally, I would not begin with many autonomous agents. I start with one coordinator and one specialist role, make the handoff durable, add a reviewer when the decision boundary needs it, and introduce parallel work only after the state model can express joins, retries, and cancellation. The number of agents is not the architecture. Durable ownership and recoverable transitions are.

FAQ

How should multi-agent workflow state be persisted?

I represent a run as an append-only event sequence plus a materialized task view. I store structured facts, task outputs, tool receipts, and decisions separately, while large inputs and payloads are referenced by content hash.

How do I recover after a worker stops during a tool call?

I resume from the last committed transition. For a pending external action, I retry with its recorded idempotency key, reconcile it against a recorded receipt, or move it to human review rather than infer the outcome from a transcript.

What makes an agent role contract enforceable?

I define each role by accepted input, allowed tools, output schema, and transition permissions. An output begins as a proposal; a validator and policy check must approve it before the orchestrator records an acceptance event.

Why separate tool execution from agent reasoning?

I treat tool execution as a state-transition boundary because a request is not evidence that an action occurred. I persist intent before dispatch and a receipt afterward, so recovery can resolve uncertainty using the tool contract.

How do I test durable multi-agent coordination?

I use replayable fixtures with initial state, scheduled events, fixed model outputs, tool receipts, and expected terminal state. I test transition legality, injected failures, role isolation, and run digests derived from persisted records.

Share this article

Related articles

  • AI Workflow Engines for Durable, Auditable Systems

    I use an illustrative LLM workflow to examine durable state, recovery, audit records, and cost controls.

    Aug 17, 202612 min read
    #AI workflows#Durable State#Retries#Audit Trails#Evals#Orchestration
  • Memory Architectures

    I separate source events from derived memory indexes, with explicit provenance, retention rules, and a recovery test plan.

    Sep 10, 202611 min read
    #AI Memory#Retrieval#Durable State#Evaluation#RAG Systems
  • How I Use Key-Management Concepts to Design Agent Evals

    Five design questions for agent evals: durable state, deterministic recovery, authorization, audit trails, and recovery playbooks.

    Apr 18, 20267 min read
    #Agent Evals#Verifiable Systems#LLM Production#MCP