Skip to content
About

Agent Patterns

Most “AI agent” problems are best solved by workflows — LLM calls composed in code you control — not by autonomous agents. These patterns run from the most predictable to the most autonomous. As always, prefer the simplest that works.

The crucial distinction:

  • A workflow has its control flow defined by you, in code. Predictable, testable, debuggable.
  • An agent has its control flow defined by the LLM, at runtime. Flexible, but harder to predict, test, and bound.

Default to workflows. Use a true agent only when the steps genuinely cannot be known ahead of time. The patterns below make this concrete.

Decompose a task into a fixed sequence of LLM calls, each consuming the last.

input call 1 call 2 call 3 output an optional check or gate can sit between steps

Use when: the task has clear, known sub-steps (outline → draft → edit). Strengths: each step is simple, testable, and debuggable. The most useful pattern there is.

Classify the input, then dispatch to a specialized handler.

input classifier Handler A — simple → cheap model Handler B — complex → strong model Handler C — specialized prompt / tools

Use when: distinct input categories deserve distinct handling. Also the core of cost-saving model routing.

Run independent LLM calls at once, then aggregate.

input Subtask A Subtask B Subtask C Aggregate Output

Two flavors: sectioning (split work into independent parts) and voting (run the same task several times for self-consistency). Use when: subtasks are independent — cuts latency and can raise quality.

A coordinator LLM breaks a task into subtasks dynamically, delegates them to workers, and synthesizes the results.

input Orchestrator decides at runtime Worker Worker Worker Synthesize Output

Use when: the subtasks can’t be known in advance — unlike fixed parallelization. This is where genuine agency begins. More flexible, less predictable.

One LLM produces; another evaluates and feeds back; loop until good enough.

no — feedback (cap the iterations) input Generator Evaluator Pass? Output yes

Use when: there’s a clear quality signal — code that must pass tests, output that must satisfy a schema, criteria a critic can apply. Weak when “good” is purely subjective. Always cap the iterations.

The full agent loop: the LLM plans, acts via tools, observes, and decides its own next step until done.

goal loop Think Act (tool) Observe result hard limits: max steps · budget · wall-clock time

Use when: the path is genuinely open-ended and can’t be expressed as any workflow above. Cost: maximum flexibility, minimum predictability — hard limits and full tracing are mandatory. See Multi-Agent & Production.

The task…Pattern
Has known, ordered sub-stepsPrompt chaining
Splits into distinct categoriesRouting
Has independent parallel partsParallelization
Needs subtasks decided at runtimeOrchestrator-workers
Has a clear quality check to iterate againstEvaluator-optimizer
Is genuinely open-endedAutonomous agent

Prefer workflows — control flow you define in code — over autonomous agents whose control flow the LLM decides. The patterns rise in autonomy: prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer, autonomous agent. Predictable workflow patterns solve most problems; the agentic ones add flexibility at the cost of predictability. Pick the simplest pattern that fits the task’s true shape.