1.1 Agent architecture: workflows, agents, and hierarchies
The tier ladder
Start at the simplest tier that meets the requirement and climb only when the requirement forces it (Building effective agents).
| Tier | What it is | Control flow | Use when |
|---|---|---|---|
| Single call | One request, one response — classification, extraction, summarization, Q&A | None | The task is fully specifiable in one prompt |
| Workflow | Multiple calls on a predefined path, orchestrated by your code | You decide the sequence | Steps are known in advance; determinism and auditability matter |
| Agent | Model decides which tool to call next until the goal is met | The model decides, in a loop | The path cannot be enumerated up front |
| Multi-agent | A manager delegates to specialised subagents | Manager decides delegation; subagents act | Work fans out, or one context cannot hold it all |
"Is this a workflow or an agent?" A fixed sequence of known steps is a workflow, even if each step calls Claude. Reaching for an agent there buys nondeterminism, higher cost, and higher latency for nothing. Reaching for a workflow when the path is genuinely unknown produces a brittle decision tree that fails on the first unanticipated request.
Workflow patterns worth naming
| Pattern | Shape | Fits |
|---|---|---|
| Prompt chaining | Output of step N is input to step N+1, with programmatic gates between | Decomposable tasks where each step is easier than the whole |
| Routing | Classify the input, then dispatch to a specialised prompt or model | Distinct input categories with different handling — cheap model for easy classes |
| Parallelization — sectioning | Split independent subtasks, run concurrently, join | Latency-bound work with independent parts |
| Parallelization — voting | Run the same task N times, aggregate | High-stakes judgment where variance is the risk |
| Orchestrator–workers | A manager decomposes dynamically and delegates to workers | The number and shape of subtasks depends on the input |
| Evaluator–optimizer | Generator produces, evaluator critiques, loop until criteria met | Clear evaluation criteria exist and iteration measurably helps |
Orchestrator–workers differs from sectioning in who decides the split: sectioning is fixed in your code, orchestration is decided by the model at runtime.
Should this be an agent at all?
Four gates. A "no" on any one of them means stay at a simpler tier.
| Gate | Question |
|---|---|
| Complexity | Is the task multi-step and hard to fully specify in advance? |
| Value | Does the outcome justify higher cost and higher latency? |
| Viability | Is Claude actually capable at this task type? |
| Cost of error | Can errors be caught and recovered — tests, review, rollback? |
The cost of error gate is the one that disqualifies most tempting candidates: an autonomous agent acting on irreversible operations (payments, deletions, outbound messages) needs a deterministic gate or a human in the loop, not more prompt instructions.
Manager / supervisor hierarchies
A manager (also called supervisor, orchestrator, or coordinator) owns everything the subagents do not:
| Manager owns | Subagent owns |
|---|---|
| Decomposition of the goal into subtasks | Execution of one scoped subtask |
| Delegation, including how many workers and with what inputs | Its own tool calls within its scope |
| Aggregation and synthesis of results | A single result returned to the manager |
| Error handling, retries, and re-delegation | Reporting failure honestly to the manager |
| The quality criteria each subtask is judged against | Nothing about the other subagents |
Subagent context is isolated. A subagent inherits nothing implicitly and shares no memory with its siblings — everything it needs must be passed in its prompt. Two consequences that items probe:
- If every subagent reports success but the aggregate output has a coverage gap, the fault is in the manager's decomposition, not in the workers.
- Passing raw content without metadata (source, URL, date, document name) makes the manager unable to reconcile conflicts or attribute claims.
What subagents actually buy
| Benefit | Mechanism |
|---|---|
| Context isolation | A verbose exploration burns the subagent's context window, not the main one — only its conclusion returns |
| Parallelism | Independent subtasks run concurrently, cutting wall-clock time |
| Specialisation | A narrow system prompt and a scoped tool list per role beats one agent holding every tool |
| Least privilege | The subagent that reads code never gets the tool that deploys it |
They cost you: extra tokens for the delegation round-trips, latency on the manager's decomposition and synthesis turns, and a harder debugging story (a failure could be decomposition, delegation, execution, or synthesis).
A single agent with a well-described tool set handles most work. Move to a hierarchy when a concrete constraint forces it — context exhaustion, genuine fan-out, or a privilege boundary you need to enforce structurally.
Quiz
- Question 1
Every invoice goes through the same four steps: classify the document type, extract the fields, validate the totals against the purchase order, and post the result to the ERP. The steps never vary, and each one is separately testable. Which architecture fits?
- Question 2
A manager agent splits a four-topic research brief into five subtasks, delegates one per subagent, and synthesises the results. Every subagent returns a complete, on-topic result; all five reach the synthesis step; none of the five contains any material on the fourth topic; and the report omits it. Where is the fault?
- Question 3
A team is deciding between an autonomous agent and a workflow. Which fact argues most strongly for the agent?
Links
- https://www.anthropic.com/engineering/building-effective-agents
- https://www.anthropic.com/engineering/multi-agent-research-system
- https://code.claude.com/docs/en/agent-sdk/overview
- https://code.claude.com/docs/en/agent-sdk/subagents
- https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview