Skip to content

Workflows vs. Agents: Six Architecture Patterns That Actually Ship

Workflows run LLMs through code paths you define; agents choose their own path. Six architecture patterns, when to use each, and how to combine them safely.

TechnoKeen Engineering 8 min read Published
On this page

A workflow runs language model calls through code paths you define. An agent lets the model choose the path. Both are useful, and most systems that make it to production are workflows with a small, well-fenced agentic core. This post walks through six patterns that cover nearly every agent system we have seen ship, with guidance on when each one is the right call and where each one breaks.

Key takeaways

  • The real design question is who owns control flow: your code or the model. Decide that per step, not per system.
  • Five of the six patterns are workflows. Reach for a fully autonomous agent only when the path genuinely cannot be predicted.
  • Patterns compose. A router can dispatch to a chain, and an agent can sit inside one branch of a workflow.
  • Every pattern needs a stopping condition, a budget, and a way to see what happened. Autonomy without observability is a debugging nightmare.
  • Start with the simplest pattern that passes your evals, then add complexity only when the evals show you need it.

The core distinction

The vocabulary here follows Anthropic’s engineering guide, Building effective agents, which is the clearest public treatment of these patterns. The guide groups them under “agentic systems” and draws one line through the middle:

  • Workflows: LLMs and tools are orchestrated through predefined code paths. You can draw the graph before the system runs.
  • Agents: the LLM dynamically directs its own process and tool usage. The graph emerges at runtime.

That distinction predicts your operational profile. Workflows have bounded cost, predictable latency, and failure modes you can enumerate. Agents trade those properties for flexibility. Neither is more advanced. If you are new to the terminology, our primer What Is Agentic AI? covers the basics.

The Python samples below assume a thin, provider-agnostic call_model(system, messages, tools=None, max_tokens=1024) helper that wraps your vendor’s SDK and returns an object with text, tool_calls, and stop_reason. Helpers like escalate and validate_incident_json stand in for your own code.

Pattern 1: Prompt chaining

Break a task into fixed sequential steps, where each model call consumes the previous output. Insert programmatic checks between steps.

Use it when the task decomposes cleanly into stages and each stage is easier than the whole. Drafting a customer-facing incident summary is a good example: extract facts from the timeline, check that required fields exist, draft the summary, then rewrite for tone.

Why it works: each call has a narrow job, so prompts stay short and outputs are easy to validate. The gates between steps catch errors before they compound.

Where it breaks: when the right next step depends on what an earlier step found. If you start adding conditional branches everywhere, you have outgrown a chain.

def incident_summary(timeline: str) -> str:
    facts = call_model(
        system="Extract impact, start time, end time, root cause, and remediation as JSON.",
        messages=[{"role": "user", "content": timeline}],
    ).text

    parsed = validate_incident_json(facts)  # raises if required fields are missing
    if parsed.root_cause is None:
        return escalate("Root cause not established; human review required.")

    draft = call_model(
        system="Write a factual customer-facing incident summary from these fields.",
        messages=[{"role": "user", "content": parsed.model_dump_json()}],
    ).text
    return draft

The gate in the middle is the point. A chain without checks is just a slower single prompt.

Pattern 2: Routing

Classify the input, then send it to a specialized handler. Each handler can have its own prompt, its own tools, and even its own model.

Use it when inputs fall into distinct categories that are better served separately. Support tickets are the classic case: billing questions, technical issues, and account changes need different context and different permissions.

Why it works: specialization. A prompt tuned for billing does not have to carry instructions for debugging API errors. Routing also lets you send easy cases to a smaller, cheaper model and reserve a more capable one for hard cases.

Where it breaks: when categories overlap or a single request spans several. Always include a fallback route for low-confidence classifications, and log every routing decision so you can audit misroutes.

from typing import Callable

ROUTES: dict[str, Callable[[str], str]] = {
    "billing": handle_billing,
    "technical": handle_technical,
    "account": handle_account,
}

def route_ticket(ticket_id: str, ticket: str) -> str:
    result = call_model(
        system=(
            "Classify the ticket as one of: billing, technical, account, unclear. "
            "Respond with the label only."
        ),
        messages=[{"role": "user", "content": ticket}],
        max_tokens=5,
    )
    label = result.text.strip().lower()
    handler = ROUTES.get(label, handle_human_queue)  # unknown or "unclear" goes to people
    log_routing_decision(ticket_id=ticket_id, label=label)
    return handler(ticket)

Pattern 3: Parallelization

Run several model calls at once and combine the results. Two variants are common:

  • Sectioning: split a task into independent subtasks. For example, review a contract for liability terms, data protection terms, and termination terms in parallel.
  • Voting: run the same task several times, or with different prompts, and aggregate. Useful for checks where a false negative is expensive, such as flagging content for policy review.

Use it when subtasks are genuinely independent or when you want more confidence than one call provides.

Where it breaks: when subtasks secretly depend on each other, or when aggregation is harder than the task. Voting multiplies cost, so reserve it for decisions where extra confidence pays.

Pattern 4: Orchestrator-workers

A central model breaks a task into subtasks at runtime, delegates them to worker calls, and synthesizes the results. Unlike parallelization, the subtasks are not known in advance.

Use it when the decomposition depends on the input. A code change that touches an unknown number of files is a good example, as is a research question whose subtopics only become clear after an initial look.

Why it works: the orchestrator plans, workers execute with focused context, and each worker’s context window stays clean.

Where it breaks: if the orchestrator decomposes poorly, every worker does the wrong job well, and synthesis must reconcile conflicting findings. This pattern sits on the line between workflow and agent and underpins most multi-agent designs. We cover those trade-offs in Multi-Agent Systems: When One Agent Isn’t Enough.

Pattern 5: Evaluator-optimizer

One model call produces an output; another evaluates it against criteria and returns feedback; the first revises. Loop until the evaluator passes it or you hit an iteration limit.

Use it when you have clear evaluation criteria and iteration measurably improves results. Translation, structured report writing, and SQL generation against a schema all fit. The pattern is most powerful when the evaluator can use a deterministic check, such as running the SQL against a test database, rather than relying on another model’s opinion alone.

Where it breaks: when the evaluator and generator share the same blind spots, or when criteria are vague enough that the loop oscillates. Always cap iterations.

def generate_sql(question: str, schema: str, max_rounds: int = 3) -> str:
    feedback = ""
    for _ in range(max_rounds):
        sql = call_model(
            system=f"Write a single read-only PostgreSQL query. Schema:\n{schema}",
            messages=[{"role": "user", "content": question + feedback}],
        ).text

        ok, error = dry_run_sql(sql)  # EXPLAIN against a replica; rejects writes
        if ok:
            return sql
        feedback = f"\n\nYour previous query failed with: {error}\nFix it."
    raise SqlGenerationFailed(question)

Notice that the evaluator here is the database, not a model. Ground truth beats opinion whenever you can get it.

Pattern 6: Autonomous agent

The model operates in a loop: decide on an action, call a tool, observe the result, repeat. It chooses which tools to use, in what order, and when it is done. This is the pattern the ReAct paper (Yao et al.) formalized.

Use it when the number and order of steps cannot be predicted, the environment gives useful feedback after each action, and success is checkable. Coding agents, open-ended investigations, and multi-system troubleshooting fit.

Where it breaks: cost and latency are unbounded unless you bound them, errors compound across steps, and the agent can take actions you did not anticipate. Every autonomous loop needs hard limits.

def run_agent(goal: str, tools: dict[str, Callable], max_steps: int = 15) -> str:
    messages = [{"role": "user", "content": goal}]
    tool_specs = [t.spec for t in tools.values()]

    for step in range(max_steps):
        response = call_model(system=AGENT_SYSTEM_PROMPT, messages=messages, tools=tool_specs)
        messages.append({"role": "assistant", "content": response.text, "tool_calls": response.tool_calls})

        if response.stop_reason != "tool_use":
            return response.text

        for call in response.tool_calls:
            tool = tools.get(call["name"])
            if tool is None:
                result = f"Error: unknown tool {call['name']}"
            elif tool.requires_approval:
                result = request_human_approval(call)  # blocks or returns a pending status
            else:
                result = tool(**call["input"])
            messages.append({"role": "tool", "tool_call_id": call["id"], "content": str(result)})

    return escalate(f"Step budget exhausted after {max_steps} steps.")

The loop itself is short. The engineering lives in the tools, the approval gates, and the budget. The quality of the tool definitions in particular determines how well the agent performs, which is why we wrote a full post on Tool Design for AI Agents.

Choosing between the patterns

The table summarizes the trade-offs.

Pattern Who controls flow Cost predictability Best for Main risk
Prompt chaining Code High Fixed multi-stage transformations Rigid when inputs vary
Routing Code, with model classification High Distinct input categories Misclassification
Parallelization Code High (but multiplied) Independent subtasks, high-confidence checks Hidden dependencies
Orchestrator-workers Model plans, code executes Medium Decomposition that depends on input Poor plans, messy synthesis
Evaluator-optimizer Code loop, model content Medium Tasks with clear criteria Oscillation, shared blind spots
Autonomous agent Model Low unless bounded Unpredictable paths with checkable outcomes Compounding errors, runaway cost

A practical decision sequence:

  1. Can a single well-designed model call with good context do it? Stop there.
  2. Can you write the steps down in advance? Use a chain, adding routing or parallelization as needed.
  3. Is there a clear quality check you can loop on? Add an evaluator-optimizer.
  4. Does the decomposition depend on the input? Consider orchestrator-workers.
  5. Is the path genuinely unpredictable, with useful feedback at each step? Use an agent, bounded by step limits, cost budgets, and approval gates.

Composing patterns in production

Real systems mix these. Consider a support platform for a B2B software company:

incoming ticket
      |
   [router] ----------------------------------------+
      |                    |                         |
  billing chain      technical agent           unclear -> human queue
  (lookup -> draft   (read-only tools: logs,
   -> policy check)   docs, account config)
      |                    |
      |             [evaluator: does the answer
      |              cite evidence from tools?]
      v                    v
           human approval for refunds or config changes
                         |
                       reply

The router and billing chain are deterministic. Only the technical branch is an agent, because diagnosing an integration error genuinely requires open-ended investigation. Write actions on both paths pass through a human approval gate. This shape is common because it confines unpredictability to the one place it earns its keep.

Cross-cutting requirements

Whatever pattern you choose, a few things are non-negotiable in production:

  • Budgets. Step limits, token limits, and timeouts on every loop.
  • Tracing. Every model and tool call recorded with inputs, outputs, latency, and cost. The OpenTelemetry GenAI semantic conventions give you a vendor-neutral schema.
  • Evals per component. Test the router’s accuracy separately from each handler’s quality.
  • Least privilege. The billing chain should not be able to touch account configuration.
  • Graceful escalation. A path to a human that preserves the work done so far.

Frameworks like LangGraph make these graphs explicit and add checkpointing for long-running workflows. You do not need one to start; most of these patterns are a few dozen lines of ordinary code.

FAQ

Is a workflow just a less capable agent?

No. A workflow is a deliberate choice to keep control flow in code, which gives you predictable cost, latency, and behavior. For tasks with known steps, a workflow will usually outperform an agent on reliability. Agents are the right tool only when that predictability cannot be achieved without losing the ability to handle real inputs.

How do I know when to move from a workflow to an agent?

Watch for branching that keeps growing. If every new edge case adds another conditional, and your evals show the workflow failing on inputs that need investigation, an agentic step may help. Move one branch at a time and compare results on the same test set.

Do these patterns require a specific framework?

No. Each pattern can be implemented in plain Python or TypeScript with a model SDK. Frameworks become useful when you need durable state, checkpointing, or human-in-the-loop interrupts across complex graphs.

How many steps should an autonomous agent be allowed to take?

Set the limit from data, not intuition. Run your eval set, look at the distribution of steps needed for successful runs, and set the cap somewhat above the typical successful run. Runs that hit the cap are a signal to investigate, not just to raise the limit.

Working with TechnoKeen

TechnoKeen designs agent architectures that put autonomy only where it pays off and keep the rest predictable. If you are deciding which pattern fits a specific process, get in touch with our engineers or review how we work.

  • #agent architecture
  • #LLM workflows
  • #design patterns

TechnoKeen Engineering

TechnoKeen is an enterprise agentic AI company. Our engineers design, deploy, and govern AI agents for organizations in regulated and complex industries, and share what we learn in the field.

About TechnoKeen →

Keep reading

Agent Architecture 8 min read

Multi-Agent Systems: When One Agent Isn't Enough

Multi-agent systems split work across specialized AI agents. Learn when they beat a single agent, which topologies work, and the coordination costs to expect.

Ready to put agents to work?

Book a 45-minute executive briefing. We will review your priority workflows, current AI efforts, and risk posture, then outline a clear path to agents in production.