Agents & Orchestration
Give a model a goal, tools, and a loop — then coordinate several toward an outcome.
By the end of this lesson, describe the agent loop and the orchestration patterns for coordinating multiple agents.
An agent is a model placed in a loop: given a goal, it reasons about the next step, calls a tool, observes the result, and repeats until done. The model supplies the reasoning; the loop, tools, and stopping conditions are engineering. Orchestration is how you coordinate one such loop reliably — and how you compose several agents into a larger workflow.
First, see the whole system. Then we’ll open it up.
The agent loop
- Given a goal, the agent reasons about the next step, calls a tool, observes the result, and checks whether the goal is met — looping until it is.
flowchart LR
goal[Goal] --> think[Reason: next step]
think --> act[Call tool]
act --> obs[Observe result]
obs --> done{Goal met?}
done -->|no| think
done -->|yes| out[Answer / outcome]The dominant pattern is ReAct — interleaving reasoning and acting so the model's next decision is informed by real observations, not just its own text. Multi-agent designs mirror the saga distinction: orchestration (a supervisor agent decomposes the goal and delegates to specialists) versus choreography (peer agents react to each other). More agents means more coordination overhead and more places to go wrong.
This is where the abstraction starts leaking.
'Autonomous agent' implies reliability it doesn't have. Each loop step is a probabilistic call that can hallucinate a tool, loop forever, or drift from the goal. The engineering — step limits, validation, guardrails, human checkpoints — is what makes an agent usable, not the model's autonomy.
Runaway / looping agent
- Trigger
- No step budget or stopping condition; the model keeps 'trying'.
- Symptom
- Endless tool calls, spiralling token cost, no convergence.
- Blast radius
- Cost, rate limits, and any side effects the tools cause.
- Mitigation
- Step limits, budgets, loop detection, validation, human-in-the-loop for risky actions.
Deep dive: Retry Storms
Multi-agent orchestration can tackle broader goals and specialize roles, but each added agent multiplies latency, cost, and failure surface. Often a single well-scoped agent (or plain workflow) is more reliable than a swarm — reach for multiple agents only when the problem genuinely decomposes.
What does the ReAct pattern interleave, and why?
Reasoning and acting — so each decision is grounded in the actual observed result of the previous tool call rather than the model's assumptions.