Agentic Workflow Patterns

The building-block patterns of agentic systems with diagrams and examples: prompt chaining, routing, parallelization (sectioning and voting), orchestrator-workers, evaluator-optimizer, plan-and-execute, reflection, and human-in-the-loop — and how to choose.

On this page

Simple definition#

Agentic patterns are reusable shapes for combining LLM calls, tools and code — the “design patterns” of AI systems. Most production systems are a composition of a few of them. They range from fully code-controlled workflows to fully model-controlled agents.

Patterns by how much control the LLM has
flowchart LR
    A["Prompt chaining"] --> B["Routing"] --> C["Parallelization"] --> D["Orchestrator–workers"] --> E["Evaluator–optimizer"] --> F["Autonomous agent"]
    L["More predictable,<br/>code decides"] -.-> A
    F -.-> R["More flexible,<br/>LLM decides"]

1. Prompt chaining#

Break a task into fixed steps; each LLM call processes the previous output. Add gates (code checks) between steps.

Prompt chaining with a gate
flowchart LR
    IN["Input"] --> S1["LLM: extract key facts"] --> GATE{"Gate:<br/>all required fields?"}
    GATE -->|"yes"| S2["LLM: draft letter"] --> S3["LLM: translate"] --> OUT["Output"]
    GATE -->|"no"| FAIL["Ask for missing info"]
  • Use when: the task decomposes cleanly into fixed sub-tasks.
  • Example: claim email → extract claim fields → validate → draft acknowledgement → translate.
  • Why it works: each call is simpler and testable; accuracy improves at the cost of latency.

2. Routing#

Classify the input, then send it to a specialised handler (prompt, model or workflow).

Routing
flowchart LR
    IN["Customer message"] --> R{"Router<br/>LLM or classifier"}
    R -->|"billing"| B["Billing prompt + tools"]
    R -->|"technical"| T["Tech-support RAG"]
    R -->|"cancellation"| C["Retention workflow"]
    R -->|"simple FAQ"| F["Small model"]
    R -->|"unclear / sensitive"| H["Human agent"]
  • Use when: inputs fall into distinct categories that are better handled separately.
  • Benefits: specialised prompts, cheaper models for easy cases (see model routing).

3. Parallelization#

Run LLM calls simultaneously and combine results programmatically.

Sectioning and voting
flowchart TB
    subgraph Sectioning["Sectioning — different sub-tasks"]
        I1["Contract"] --> A1["LLM: liability clauses"]
        I1 --> A2["LLM: termination clauses"]
        I1 --> A3["LLM: data-protection clauses"]
        A1 --> M1["Merge into review"]
        A2 --> M1
        A3 --> M1
    end
    subgraph Voting["Voting — same task, several times"]
        I2["Code change"] --> V1["LLM reviewer 1"]
        I2 --> V2["LLM reviewer 2"]
        I2 --> V3["LLM reviewer 3"]
        V1 --> M2{"Majority /<br/>any flags?"}
        V2 --> M2
        V3 --> M2
    end
  • Sectioning — independent sub-tasks in parallel (speed, focus). Also: one call answers while another checks guardrails.
  • Voting — same task several times for confidence (security review, content moderation).

4. Orchestrator–workers#

A central LLM breaks a task into sub-tasks dynamically, delegates them to worker LLMs, and synthesises the results. Unlike sectioning, the sub-tasks are not known in advance.

Orchestrator–workers
flowchart TB
    T["Task: 'Assess impact of new<br/>EU regulation on our products'"] --> O["Orchestrator LLM<br/>plans sub-tasks"]
    O -->|"sub-task 1"| W1["Worker: summarise regulation"]
    O -->|"sub-task 2"| W2["Worker: list affected products"]
    O -->|"sub-task 3"| W3["Worker: check current controls"]
    W1 --> S["Orchestrator synthesises"]
    W2 --> S
    W3 --> S
    S --> R["Impact report"]
  • Use when: the number and nature of sub-tasks depend on the input (research, multi-file code changes).
  • This is the basis of the supervisor pattern in multi-agent systems.

5. Evaluator–optimizer#

One LLM generates; another evaluates against criteria and gives feedback; repeat until good enough.

Evaluator–optimizer loop
flowchart LR
    IN["Task"] --> G["Generator LLM"]
    G --> D["Draft"]
    D --> E{"Evaluator LLM<br/>meets criteria?"}
    E -->|"no + feedback"| G
    E -->|"yes"| OUT["Final"]
    E -->|"max rounds"| OUT
  • Use when: clear evaluation criteria exist and iteration measurably helps (translation nuance, SQL that must pass tests, policy-compliant marketing copy).
  • Use deterministic evaluators where you can: unit tests, schema validation, SQL EXPLAIN, linters.

6. Plan-and-execute#

The agent writes an explicit plan first, executes steps (often with a cheaper model or plain code), and re-plans when results differ from expectations.

Plan, execute, re-plan
flowchart TD
    G["Goal"] --> P["Planner LLM:<br/>numbered plan"]
    P --> X["Executor:<br/>run next step with tools"]
    X --> C{"Step result<br/>as expected?"}
    C -->|"yes, more steps"| X
    C -->|"no"| RP["Re-plan with<br/>what was learned"]
    RP --> X
    C -->|"all done"| F["Final answer"]
  • Benefits: the plan is visible (users and reviewers can approve it), cheaper execution, better long-horizon behaviour.
  • Variants: ReWOO (plan all tool calls up front), LLMCompiler (plan a DAG of parallel calls).

7. Reflection#

The agent critiques its own output or failed attempts and stores lessons for the next try (Reflexion). Cheaper than a separate evaluator, but self-critique is less reliable than external checks — prefer real signals (test results, tool errors) as the input to reflection.

8. Human-in-the-loop (HITL)#

A pattern that combines with all others: pause at defined points for human approval, correction or input.

Approval checkpoint
sequenceDiagram
    participant A as Agent
    participant S as State store
    participant H as Human approver
    participant SYS as Payment system
    A->>A: decides: refund €480 to customer C-301
    A->>S: checkpoint state, status = AWAITING_APPROVAL
    A-->>H: approval request with reasoning and evidence
    Note over A,H: Agent paused — minutes or days
    H->>S: approve (or edit amount / reject)
    S->>A: resume from checkpoint
    A->>SYS: refund(C-301, 480, idempotencyKey)
    A-->>H: done, audit record written

Requires durable state (checkpoints) so the agent can wait without holding a thread; see memory and state.

Choosing a pattern#

Situation Pattern
Fixed steps, each simpler than the whole Prompt chaining
Distinct input categories Routing
Independent sub-tasks, or need confidence Parallelization
Sub-tasks unknown until runtime Orchestrator–workers
Clear quality criteria, iteration helps Evaluator–optimizer
Long multi-step tasks needing a visible plan Plan-and-execute
Open-ended, path unknowable Autonomous agent (ReAct loop)
Risky or irreversible actions + Human-in-the-loop

Common mistakes#

Review questions#

What is the difference between prompt chaining and an agent? In prompt chaining, code defines a fixed sequence of LLM calls with checks between them. In an agent, the LLM decides the next step at runtime in a loop.

When would you use orchestrator–workers instead of parallel sectioning? When sub-tasks cannot be known in advance and depend on the input — the orchestrator plans them dynamically. Sectioning uses a fixed, predefined split.

Explain the evaluator–optimizer pattern. A generator produces output, an evaluator checks it against explicit criteria and returns feedback, and the generator revises — looping until criteria are met or a round limit is reached. Use deterministic evaluators such as tests where possible.

What is plan-and-execute and why use it? A planner produces an explicit multi-step plan, an executor runs steps with tools, and the planner re-plans when results deviate. It makes long tasks more reliable, visible and cheaper.

How do you implement human-in-the-loop in an agent? Define checkpoints for risky actions, persist the agent’s state, notify an approver with context, resume from the checkpoint after approval or edit, and log the decision.

Summary#

  • Patterns range from code-controlled (chaining, routing, parallelization) to model-controlled (orchestrator–workers, agents).
  • Evaluator–optimizer, plan-and-execute and reflection improve quality on hard tasks.
  • Human-in-the-loop adds safety to any pattern and needs durable state.
  • Choose the simplest pattern that meets requirements; compose patterns for real systems.

References#