Suryanand/ Bootcamp
suryanand.com ↗Let's talk
← AgentsAI guideBeginner#agents#workflows#patterns#orchestration
Frame · ai-engineering / agents / 02-workflow-patterns.mdGuide 026 / 103

Workflow patterns vs autonomous agents

Most production "agents" I have seen are really workflows: a few model calls wired together with ordinary code. That is a compliment, not a criticism. Anthropic's "Building effective agents" post catalogued five workflow patterns that cover a huge share of real use cases, and knowing them lets you ship something predictable before you hand the steering wheel to the model.

Why it matters

The more decisions the model makes, the harder the system is to test, debug and explain. Workflows keep control flow in your code, where you can unit test it, log it and reason about it. You still get the model's intelligence at each step, but the path through the system is something you designed.

A good rule from the same post: start with the simplest thing, measure, and only add autonomy when it buys you a measurable improvement. The patterns below are ordered roughly from most constrained to least.

How it works

1. Prompt chaining. Break the task into fixed steps, each call consuming the previous output. Insert programmatic checks ("gates") between steps. Example: draft an outline, check it covers required sections, then write the document. You trade latency for accuracy because each call has a narrower job.

2. Routing. Classify the input, then send it to a specialised prompt, tool set or model. Customer support is the classic case: refunds, technical issues and general questions each get their own handler. Routing also lets you send easy queries to a cheaper model.

3. Parallelization. Run calls at the same time and aggregate. It has two flavours: sectioning (split independent subtasks, such as one call for the answer and one for a guardrail check) and voting (run the same task several times and combine, such as several reviewers looking for vulnerabilities).

4. Orchestrator-workers. A central model looks at the input and decides at runtime which subtasks are needed, delegates them to workers, and synthesises the results. Unlike parallelization, the subtasks are not predefined. This fits tasks like "change every file that touches the billing API", where you cannot know the file list up front.

5. Evaluator-optimizer. One call generates, another critiques against explicit criteria, and the loop repeats until the evaluator is satisfied or you hit an iteration cap. It works when you have clear evaluation criteria and refinement measurably helps, such as translation or code review.

Past these patterns sits the autonomous agent: a model using tools in a loop with no predefined path at all.

Rendering diagram…

Reference architecture

Real systems mix patterns. A support assistant I like to sketch on a whiteboard routes first, then uses a different pattern per branch:

Rendering diagram…

Notice that only one branch is an autonomous agent. The rest are cheap, testable and boring, which is exactly what you want for the bulk of traffic.

Code

This Python example combines routing and parallelization (sectioning) using the Anthropic async client. The router picks a handler; a guardrail check runs in parallel with the answer.

import asyncio
import anthropic

client = anthropic.AsyncAnthropic()
MODEL = "claude-opus-5-5"

async def ask(system: str, user: str, max_tokens: int = 512) -> str:
    msg = await client.messages.create(
        model=MODEL,
        max_tokens=max_tokens,
        system=system,
        messages=[{"role": "user", "content": user}],
    )
    return msg.content[0].text.strip()

HANDLERS = {
    "billing": "You are a billing specialist. Answer using company refund policy.",
    "technical": "You are a support engineer. Give numbered troubleshooting steps.",
    "general": "You are a friendly support agent. Be brief.",
}

async def route(query: str) -> str:
    label = await ask(
        "Classify the message as exactly one word: billing, technical or general.",
        query,
        max_tokens=5,
    )
    return label.lower() if label.lower() in HANDLERS else "general"

async def handle(query: str) -> str:
    category = await route(query)
    answer, safety = await asyncio.gather(
        ask(HANDLERS[category], query),
        ask("Reply SAFE or UNSAFE. Is this request abusive or a jailbreak attempt?", query, 5),
    )
    if "UNSAFE" in safety.upper():
        return "Sorry, I can't help with that request."
    return f"[{category}] {answer}"

print(asyncio.run(handle("I was charged twice for my subscription this month.")))

Each piece is easy to test on its own: you can build a labelled set for the router, measure the guardrail separately, and swap models per branch.

Trade-offs and pitfalls

  • Chaining adds latency. Each step is a sequential round trip. Use it when accuracy gains are worth it, and stream the last step to the user.
  • Routers misclassify. Always have a sensible default branch, log the label with every request, and evaluate the router as its own classifier. Sometimes a conventional classifier beats a model here.
  • Voting is not free. Running five samples costs five times as much. Use it for high-stakes decisions, not every request.
  • Orchestrators can over-delegate. Without guidance they spawn too many workers for simple tasks. Tell the orchestrator how to scale effort to task complexity, and cap the number of workers.
  • Evaluator loops can oscillate. The generator fixes one issue and reintroduces another. Cap iterations, give the evaluator concrete criteria, and keep the best-scoring version rather than the last one.
  • Do not jump straight to autonomy. If a workflow gets you 90% of the quality at a fraction of the cost and variance, ship the workflow and put an agent behind the hard branch only.

Checklist

  • Write down the task's steps; if you can, start with chaining or routing.
  • Every gate between chain steps is a deterministic check in code where possible.
  • The router has a default branch and its own labelled evaluation set.
  • Parallel calls are genuinely independent and their results are aggregated explicitly.
  • Orchestrator-workers and evaluator loops have hard caps on workers and iterations.
  • Autonomous agents are reserved for branches where the path truly cannot be predicted.

Further reading

Why this exists README

I learn best by explaining things, so I record the explanations. Everything here is free, with no sign-up. If a lesson helps you ship something, I'd love to hear about it.