# Agent Orchestration in Production: Architecture, Patterns, and Failure Modes

> A field guide to coordinating coding agents: the control loop, durable state, claims, verification, budgets, and the failures I found while running a twenty-agent fleet.

- Canonical: https://jedarden.com/guides/agent-orchestration/
- Published: 2026-10-11
- Last verified: November 30, 2026 (2026-11-30)
- Tags: agents, agent-orchestration, multi-agent-systems, fleet-ops

---

**AI agent orchestration is the control system around an agent's work.** It decides
which task can start, gives that task to one worker, limits what the worker can
reach and spend, checks the result, and decides what happens next. The model
does the uncertain part; the surrounding system keeps that uncertainty from
turning into lost work, duplicate work, or an unattended retry loop.

I learned the distinction by running about twenty headless coding agents at
once. The incidents in [my fleet failure
taxonomy](/notes/what-breaks-at-twenty-agents/) happened in the queue, host,
deploy path, and test environment more often than in the agent itself. This
guide is the architecture I use to reason about those seams. It is a report
from one coding-agent fleet, not a benchmark of every agent framework.

## When orchestration becomes necessary

A single, supervised session can rely on a person to notice a stalled task,
choose the next one, and decide whether the answer is good. The moment work
continues without that person, those decisions need an owner and a durable
record. A multi-agent architecture adds a second problem: two workers can see
the same ready task or edit the same file at the same time.

My first move was to make each worker replaceable: it reconstructs its context
from the task, repository, and standing instructions, then can be restarted
without recovering a precious chat session. That changed which work was safe
to dispatch and exposed the missing control loop. The experience and its
tradeoffs are in [Pet agents vs. cattle
agents](/notes/agents-pets-cattle/); the artifact handoff is documented in
[the workflow manual](/guides/workflow/#s01-the-whole-loop).

Use orchestration when you need unattended continuation, more than one worker,
or an auditable answer to "why did this task run?" A person driving one agent
through an exploratory problem may only need a task list and an independent
check of the result.

## Three things people mean by agent orchestration

The term covers different control problems. This distinction comes from
[building a deterministic state machine around my own
agents](/notes/deterministic-state-machines-for-agents/), alongside my
[workflow-engine CI implementation](/guides/ci-on-rackspace-spot/):

<div class="ao-context-table" role="region" aria-label="Coordination settings comparison" tabindex="0">

| Setting | Unit being coordinated | What must survive an interruption |
| --- | --- | --- |
| Conversational collaboration | Turns, tool calls, and handoffs within a session | The useful decisions and context from that conversation |
| Workflow engine | Predetermined steps and their inputs and outputs | Step state, artifacts, and retry history |
| Coding-agent fleet | Replaceable workers taking repository tasks | Claims, task intent, work on disk, verification, and outcome history |

</div>

These are design lenses, not a vendor ranking. I use a workflow engine for
known CI steps and a task queue plus outcome handlers for coding work whose
path cannot be scripted in advance. A conversation is useful for discovery;
before unattended dispatch I put its decisions into task and repository
artifacts. [The plan is the prompt](/notes/plan-is-the-prompt/) shows what
must be written down for a fresh worker to start well.

## A production architecture and one task's lifecycle

Here is the smallest useful diagram of the fleet I run. It omits provider and
deployment details deliberately; [NEEDLE's source](https://github.com/jedarden/NEEDLE)
and [the state-machine account](/notes/deterministic-state-machines-for-agents/)
show the implementation and the outcome table behind it.

<div data-orchestration-exhibit="loop">

```text
plan + acceptance checks
          |
          v
  dependency-aware queue --atomic claim--> worker + bounded context
          ^                                  |
          |                                  v
   retry / defer / stop <-- outcome handler <-- independent verification
          |                                  |
          +----------- durable record <-----+
```

**Illustrative state machine.** These paths explain a control policy; they are not measured runs, timings, or outcome frequencies. Ready → atomic claim → worker → independent verification → outcome handler → durable record. A lost claim returns to the queue before work starts. A timeout or a human decision can interrupt before verification.

| Observed outcome | Durable next state | Handler |
| --- | --- | --- |
| Checks pass | Closed with evidence | Record the artifact and successful checks, close the task, and release the claim. |
| Checks fail | Open for diagnosis | Record the failing check. Retry only when there is a concrete correction and budget remains. |
| Gate cannot run | Waiting on verification | Record the broken verification dependency and repair it before judging the artifact. |
| Worker times out | Reconcile before retry | Inspect durable writes, reconcile the claim, and retry only within the remaining budget. |
| Another worker wins claim | Select other ready work | Do not start this task. Return to the ready queue without changing the winning claim. |
| Human decision required | Waiting on a decision | Record the exact decision and stop dependent work until it arrives. |

With JavaScript, choose an outcome and replay the corresponding path. Only passing independent verification permits closure.

</div>

In one pass, the controller selects ready work, claims it once, constructs a
bounded task context, dispatches an agent, then classifies the result. The
classification matters more than the launch: a lost claim race, an agent
failure, a broken verification gate, a provider outage, and verified completion
need different handlers. My original six-row table grew when those cases
proved different in operation; [the later outcome additions are recorded in
the state-machine note](/notes/deterministic-state-machines-for-agents/#five-months-later-six-rows-became-nine).

The queue carries dependencies as well as assignments. Cutting tasks so that
parallel workers do not touch the same function is a planning decision, not
something an atomic claim can solve. [The manual's decomposition
section](/guides/workflow/#s06-decomposition-is-concurrency-control) walks
through that second concurrency boundary.

## State, claims, retries, and idempotency

I keep task state outside the agent session. A claim must be atomic, because
"list ready tasks, then mark one mine" lets two workers begin the same task.
The queue must also know whether the claimant is still alive: an abandoned
claim is work that is neither done nor available. [The atomic-claims
walkthrough](/guides/workflow/#s07-atomic-claims)
and [the leaked-claim incident](/notes/what-breaks-at-twenty-agents/#7-the-claims-that-leak)
are the evidence for both rules.

Retries need a boundary. A timeout or temporary provider error may justify a
new attempt; a task with contradictory acceptance checks will burn the same
budget repeatedly. I record the failure class and cap attempts, then send
structural failures to review. [The death-loop
incident](/notes/what-breaks-at-twenty-agents/#2-the-bead-that-never-stops-failing)
is why the stop rule exists.

An idempotent action can be repeated without adding another effect. Before
retrying interrupted repository work, I reconcile durable evidence such as the
commit, task closure, and verification result. Reconciliation tells me which
effects already landed and which work remains.
"The process exited" alone cannot tell me whether its last write landed.
[The attempt-resolution design](https://github.com/jedarden/NEEDLE/blob/main/docs/adr/024-attempt-evidence-resolution-is-the-unit-of-work.md)
records why a process exit is only an observation, while [the queue repair
incident](/notes/what-breaks-at-twenty-agents/#5-the-repair-that-ate-the-queue)
shows why I identify the authoritative state before rebuilding from a
checkpoint.

## Isolation, secrets, and verification

I bound a worker's filesystem and credential access to the work it owns, and I
separate test state from live task state. A fleet test once wrote synthetic
claims into real work queues across many repositories; the [test-pollution
incident](/notes/what-breaks-at-twenty-agents/#6-the-test-run-that-lied-to-twenty-two-repos)
explains why a test needs its own discovery scope and store.

Instructions alone cannot protect a secret available to the process. In my
setup, the agent's environment and credential access are constrained before
dispatch; [the credential-boundary
note](/notes/ignore-env-is-not-a-defense/) describes the failure that led
there. The broader rule is to grant the smallest capability a task needs and
make a sensitive action reversible or independently reviewable, as in [the
trust model](/notes/trust-is-a-property-of-the-system/).

Verification must be independent of the worker's claim that it succeeded.
Tests and acceptance checks run against the produced artifact, and a gate that
could not run is a different outcome from a gate that ran and failed. [Don't
let the agent grade its own homework](/notes/dont-let-the-agent-grade-its-own-homework/)
shows the original lesson; [the gate-error outcome](/notes/deterministic-state-machines-for-agents/#five-months-later-six-rows-became-nine)
shows how it changed the control loop.

## Budgets and observability

Unattended workers remove the person who used to notice a runaway session.
I bound an attempt by time and work, govern the number of concurrent workers,
and measure spend against verified completed tasks. Token totals alone hide
whether the fleet delivered anything. [The unit-economics
note](/notes/unit-economics-of-cattle/) records the cost model and where it
still falls short.

For operations, I watch the ready queue, claim age, outcome mix, completion
rate, and spend rate. An alert saying "starved" is only a hypothesis until I
check the queue from the right workspace; I have seen parsing and directory
errors create false starvation. [The operator's-day
section](/guides/workflow/#s10-the-operators-day) gives the actual signals I
use. [The twenty-agent incidents](/notes/what-breaks-at-twenty-agents/)
show why host health and worker launch also belong in the picture.

## What the fleet measurements tell me to budget

The [Codex and Claude Code field comparison](/guides/codex-vs-claude-code/)
measured my fleet through October 31, 2026. These three views use the adapter
that actually ran each attempt, rather than the worker name. The attempt
traces cover September 12–October 31: 49 days within the report's nominal
60-day window. Four executed groups are shown; 50 unassigned or legacy
attempts are omitted. The task mix was not randomized, and the Anthropic
sample is only 91 attempts. These observations help size a control loop;
they do not rank model capability.

<div data-orchestration-exhibit="attempts">

| Executed harness | Attempts |
| --- | ---: |
| Codex CLI | 9,708 |
| Claude Code · Anthropic | 91 |
| Claude Code · GLM | 8,302 |
| Other (OpenCode / ZCode) | 190 |

</div>

<div data-orchestration-exhibit="yield">

| Executed harness | Verified / attempts | Yield | Yield excluding splits |
| --- | ---: | ---: | ---: |
| Codex CLI | 4,843 / 9,708 | 49.9% | 60.7% |
| Claude Code · Anthropic | 20 / 91 | 22.0% | 23.5% |
| Claude Code · GLM | 3,303 / 8,302 | 39.8% | 42.5% |
| Other (OpenCode / ZCode) | 102 / 190 | 53.7% | 57.0% |

Yield is verified attempts divided by attempts. Split-decompositions schedule child tasks instead of delivering the parent, so the final column removes them from the denominator.

</div>

<div data-orchestration-exhibit="duration">

| Executed harness | Median attempt |
| --- | ---: |
| Codex CLI | 5.9 min |
| Claude Code · Anthropic | 6.6 min |
| Claude Code · GLM | 28.2 min |
| Other (OpenCode / ZCode) | 5.8 min |

Process wall-clock includes verification gates. It does not measure active thinking time or time to a completed task.

</div>

The counts tell me where most of the retry and verification traffic came
from. Yield tells me to budget for attempts that do not deliver, including
useful task splits. Duration tells me to measure a timeout against the
actual workload: a short median for one adapter does not justify the same
budget for another. None of these numbers establishes a safe retry cap or
a current vendor limit.

## Failure modes that changed the design

The [fleet incident log](/notes/what-breaks-at-twenty-agents/) is the
source for this short list; each linked case includes the symptom, cause, and
rule I took from it.

| What I saw | Control-plane change |
| --- | --- |
| [Workers died during simultaneous launch](/notes/what-breaks-at-twenty-agents/#1-the-fleet-you-launch-is-not-the-fleet-you-get) | Stagger creation and count workers that actually started. |
| [The same impossible task retried all night](/notes/what-breaks-at-twenty-agents/#2-the-bead-that-never-stops-failing) | Cap attempts and escalate structural failure. |
| [A deploy stranded live workers](/notes/what-breaks-at-twenty-agents/#3-the-deploy-that-stranded-fifteen-workers) | Drain and reconcile claims before changing the live launch path. |
| [Claims outlived their workers](/notes/what-breaks-at-twenty-agents/#7-the-claims-that-leak) | Use leases and reconcile liveness before releasing work. |

The common failure was an unmodeled seam. Naming each outcome and deciding
who owns its recovery made the fleet easier to operate than adding another
prompt instruction would have.

## Choosing a control tool

This is a decision table, not a head-to-head performance test. I evaluate a
tool against four requirements: **durable task state**, **exclusive claims**,
**an explicit failure handler**, and **independent verification**. The rows
reflect only approaches I have operated: [a person-operated task
loop](/guides/workflow/#s01-the-whole-loop), [NEEDLE](https://github.com/jedarden/NEEDLE),
and [Argo Workflows for CI](/guides/ci-on-rackspace-spot/).
Argo exposes [retry policies and limits](https://argo-workflows.readthedocs.io/en/latest/walk-through/retrying-failed-or-errored-steps/);
I still have to decide which failures my workload should retry.

| Approach I have used | Good fit in that use | Work I still have to supply |
| --- | --- | --- |
| Person-operated task tracker | Learning the task partition and handoffs with a person present | The person handles stalled work, budgets, and outcome routing. |
| Task queue plus a coding-agent controller | Unattended repository tasks with replaceable workers | Task design, claim recovery, verification gates, and spend policy. |
| Workflow engine for fixed CI stages | A known sequence of build and test steps | A separate contract to classify an agent's open-ended work before deciding what to retry. |

Start with the least machinery that can satisfy those four requirements for
your actual workload. A framework name does not supply the missing task
contract. I would test an unfamiliar product with one task that fails, one
that times out, and two workers racing for the same claim before trusting its
happy-path demo.

## Source and deeper field notes

The design here is inspectable: [NEEDLE's public
repository](https://github.com/jedarden/NEEDLE) contains the controller;
[a timeout configuration fixture](https://github.com/jedarden/NEEDLE/blob/main/tests/fixtures/timeout-config-fast-iteration.yaml)
shows concrete attempt and worker bounds; and [the outcome-handling
investigation](https://github.com/jedarden/NEEDLE/blob/main/docs/analysis/outcome-handling-leak-root-cause.md)
records how a completed attempt left its task claimed after a worker died.
The [workflow manual](/guides/workflow/) shows the planning and queue protocol;
[the state-machine note](/notes/deterministic-state-machines-for-agents/)
records outcome evolution; and [the twenty-agent failure
taxonomy](/notes/what-breaks-at-twenty-agents/) is the incident index. For
specific boundaries, see [credential isolation](/notes/ignore-env-is-not-a-defense/),
[independent verification](/notes/dont-let-the-agent-grade-its-own-homework/),
and [cost per closed task](/notes/unit-economics-of-cattle/).