LLM Lab

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.

Where this sits in a LangGraph application
State→Nodes→Edges & routing→Parallel (Send)→Checkpoints & interrupts→Several agents

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()
Routing as a LangGraph graph: a classifier node, then a conditional edge that picks the next node from the state.

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.

chaining
step 1→step 2→step 3
routing
classify→billing | tech | other
parallel
split→3 calls at once→merge
orchestrator
plan→workers→combine
evaluator
draft→critique→revise
Five workflow patterns as small pipelines. Each is code that calls the model at fixed points; an agent instead lets the model decide the next step itself.

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

Check yourself · 1 of 3

Support tickets about billing, bugs and refunds each need different handling. Which pattern fits?

Check yourself · 2 of 3

When is a fully autonomous agent the right choice over a fixed workflow?

Check yourself · 3 of 3

Translation where a second model critiques and the first revises, until good enough, is…

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.
All books
Labpattern switcher
How to read this
  • Pick a pattern from the tabs. The diagram shows how the model calls are wired together, and the text explains when to use it.