Workflow patterns
Most useful LLM systems are not open-ended agents. They are a few model calls wired together in a fixed pattern, and the pattern matters more than the prompt.
Workflows and agents
In a workflow, code decides the path: which call happens next is fixed in advance. In an agent, the model decides its own next step in a loop. Start with the simplest thing that works and add structure only when it clearly helps.
Five common patterns
Pick a pattern in the lab to see its shape, an example, and when to use it. This grouping follows Anthropic’s write-up “Building effective agents”.
In LangGraph
Each pattern is a small graph. Chaining is a line of nodes; routing is a conditional edge; parallel work is several edges out of one node; orchestrator-workers starts one worker per subtask with Send; evaluator-optimiser is a conditional edge that loops back to the generator. The next lessons build each piece.
def route(state: State) -> str:
return state["topic"] # "billing", "tech" or "other"
builder = StateGraph(State)
builder.add_node("classify", classify)
builder.add_node("billing", billing)
builder.add_node("tech", tech)
builder.add_node("other", other)
builder.add_edge(START, "classify")
builder.add_conditional_edges("classify", route, ["billing", "tech", "other"])
graph = builder.compile()A worked example
A support assistant can route each message (billing, technical, other) to a specialised prompt; for a long report it can chain outline → draft → edit; for a code review it can run security, style and test checks in parallel and merge them; an orchestrator can split a research question into sub-questions for workers; and an evaluator can critique a translation until it meets a checklist.
In practice
Start with the simplest pattern that works. Fixed workflows are easier to test, cheaper and more predictable than a free agent; reach for an agent only when the steps cannot be known in advance.
Easy to confuse
- A workflow is code that calls the model at fixed points; an agent lets the model choose the next step.
- Patterns combine: a router can send some requests to a chain and others to an agent.
Support tickets about billing, bugs and refunds each need different handling. Which pattern fits?
A first call classifies the input and sends it to a specialised prompt or tool set.
When is a fully autonomous agent the right choice over a fixed workflow?
Workflows are cheaper and more predictable; agents earn their cost when the path depends on what is discovered along the way.
Translation where a second model critiques and the first revises, until good enough, is…
One call generates, another evaluates and gives feedback, in a loop.
Read more in the books
- LangChain and LangGraph documentation, LangChain: LangGraph: Workflows and agents.
- AI Engineering, Chip Huyen: Ch. 6, “RAG and Agents”: agents.
- AI Engineering, Chip Huyen: Ch. 10, the AI engineering architecture.