insideout Get Pro

02 · Fixed workflow or open loop

Free

Agents, lesson 2

Fixed workflow or open loop

When a scripted chain of calls beats letting the model choose.

An agent lets the model choose every next step, and you pay for that freedom in calls, cost and surprises. Often a path written in code does the same job for less. This lesson shows how to tell which a task needs and what each costs; you need the agent loop from "Observe, decide, act".

By the end, you can:

  1. Tell a workflow from an agent by who picks the next step, and count the calls each makes.
  2. Name the five common workflow shapes, and count the model calls each one makes.
  3. Work out how a per-step success rate shrinks over a long run.
  4. Pick a workflow or an agent for a task, and price the choice in model calls.

Part 1. Who picks the next step

Tell a workflow from an agent by who picks the next step, and count the calls each makes.

A hotel booking desk gets this email: "My flight on the 14th was cancelled. Can I move my hotel to the 15th, or get my money back?" You can handle it two ways, with the same model and tools. What differs is who decides the next step.

Example 1.1

One email, two ways

Handle the email along a path written in code, then with an agent that has six tools: find booking, read policy, check availability, change booking, refund, send reply. Count the model calls.

  1. Path: label the emailcall 1 → "date change"

    The model picks one of three labels your code knows.

  2. Path: look up and check0 model calls

    Your code finds the booking and asks the hotel's system if the 15th is free.

  3. Path: draft the replycall 2 → the reply

    A second prompt gets the email, the booking and the answer, and writes the reply.

  4. Agent: let it loop5 tools + 1 answer = 6 calls

    This run: find, read the policy, check, change, send, then answer. Next run it may read the policy twice, or refund instead.

Answer2 calls along the path, every time. 6 for the agent on this run, and maybe a different number next time.

Along the path, your code decides what comes next, and the model only reads and writes inside each step. In the agent the model decides: each tool result shapes its next move, which is what lets it cope with an email nobody planned for.

Workflow and agent

A workflow strings model calls and tools along a path written in your code. An agent lets the model choose each next step in a loop. Anthropic's "Building effective agents" (2024) calls both agentic systems.

workflow: your code picks the next step; agent: the model does

The line is about control, not tools or loops. A workflow can call tools and repeat a step a fixed number of times. If your code decides the next step, it's a workflow; if the model's reply decides, it's an agent.

Your turn

Every invoice PDF goes through the same three steps: pull out the fields, check the totals add up, write a row to the database. Which fits?

If you can write the steps down in advance, write them in code. The model still does the hard part inside each step (reading a messy PDF), but nothing is gained by letting it choose the order. You'd only pay for that freedom in calls and surprises.

Part 2. Five shapes of workflow

Name the five common workflow shapes, and count the model calls each one makes.

Most workflows are one of five shapes, or a few of them nested. The names come from Anthropic's "Building effective agents", and most agent frameworks use them.

Example 2.1

Calls per input, shape by shape

Count the model calls for one input in each shape: a two-step chain; a router with three handlers; three answers that vote; a planner that splits a change across 3 files; a writer and grader whose draft passes on round 3.

  1. Prompt chaining1 + 1 = 2

    An outline, then the post. A code check between them can stop the chain early.

  2. Routing1 + 1 = 2

    One call labels the input, then one of the three handlers runs.

  3. Parallelization, voting3

    Three calls answer the same question, and code takes the majority. Sectioning gives each call a slice instead.

  4. Orchestrator-workers1 + 3 + 1 = 5

    One call plans, a worker takes each file, one call combines. Another change might need 7 workers.

  5. Evaluator-optimizer3 × 2 = 6

    Each round is a draft and a grade, until the draft passes or a round limit is hit.

Answer2, 2, 3, 5 and 6 calls. The last two change from input to input.

model callplain codePrompt chaining2 callsoutlinecheckpostRouting2 callslabelone handler runsParallelization, voting3 callsvotesame question, 3 timesOrchestrator-workers5 callsplancombinethe plan sets nEvaluator-optimizer6 callswritegradenotespass, or hit the cap
Figure 1The five shapes and their calls in the example. Circles are model calls, dashed squares plain code. Only the last two let a model decide the count.

The first three fix their calls in advance. In the last two a plan or a grade decides, so they sit closer to an agent. They stay workflows because your code still owns the loop: it runs the plan and caps the rounds.

The five workflow shapes

Prompt chaining feeds each call's output to the next. Routing labels the input and sends it to one handler. Parallelization runs calls at once, on slices or as votes. Orchestrator-workers lets one call plan the subtasks. Evaluator-optimizer loops a writer and a grader.

None of these needs a framework: a chain is a few function calls, routing an if on a label, parallel calls asyncio.gather. Anthropic advises starting with the model's API directly, where you see every prompt.

Your turn

Product pages are translated into German. One call translates, and a second checks the result against a glossary and sends back fixes, until it passes or 4 rounds are up. A page passes on round 2. Which shape is this, and how many model calls did the page take?

Write, grade, send notes back: evaluator-optimizer. Each round is a translation and a check, and this page stopped after round 2: 2 × 2 = 4. 8 is the cap of 4 rounds, which this page never reached.

Part 3. Small slips multiply

Work out how a per-step success rate shrinks over a long run.

Every step is a chance to slip: a wrong tool, a misread number, a bad argument. If one uncaught slip spoils the result, a long run needs every step to go right.

Example 3.1

Thirty steps at 99%

Each step of an agent's run is right 99% of the time, and any slip spoils the result. What share of 30-step runs come out clean? And how good must each step be for 90% of runs to come out clean?

  1. Two steps0.99 × 0.99 = 0.98

    Both have to go right, so multiply the chances.

  2. Thirty steps0.99³⁰ = 0.74

    Multiply 0.99 by itself 30 times.

  3. Turn it roundp³⁰ = 0.90

    Find the per-step chance p that, multiplied by itself 30 times, gives 0.90.

  4. Solve for p0.90^(1/30) = 0.9965

    The 30th root of 0.90. On a calculator, raise 0.9 to the power 1 ÷ 30.

Answer74% of runs come out clean. For 90%, each step must be right 99.65% of the time.

0%25%50%75%100%0102030405060steps in the run90%74%40%99.65% a step99% a step97% a stepRuns with no uncaught slip
Figure 2The share of runs with no uncaught slip, by number of steps. At 99% a step, only 74% of 30-step runs come out clean.

Each step multiplies the chance of a clean run by a number just under 1, so it keeps falling as runs get longer. A 3-step workflow barely notices; a 30-step agent feels every point of error. Anthropic warns that an agent's autonomy brings higher costs and compounding errors.

Compounding errors

When a run succeeds only if every step does, its chance of success is the product of the steps' chances. Small error rates per step grow into large failure rates over a long run.

P(clean run) = pⁿ, for n steps each right with chance p

That sum assumes every slip is final. Many aren't. A failing test, an error message or an empty search is an observation, and the model can read it and try something else: that slip costs a step. The slips that multiply are the silent ones, like a wrong number copied into a reply.

Your turn

A 10-step run, where each step is right 95% of the time and any uncaught slip spoils the result. About what share of runs come out clean?

Multiply: 0.95¹⁰ ≈ 0.60. 95% is one step's chance, not the run's. 50% takes away 10 × 5%, which only works for tiny error rates. About 40% is the share that fail.

Part 4. Choosing for the task

Pick a workflow or an agent for a task, and price the choice in model calls.

One test settles most cases: could you write the steps down before you see the input? For filling in a form, yes. For reproducing a bug from a two-sentence report, no: what you try next depends on what the logs show. Many inboxes are mostly the first kind.

Example 4.1

A thousand emails a day

The booking desk gets 1,000 emails a day: 900 routine, like a date change, and 100 odd cases. An agent averages 6 calls an email, and 8 on the odd ones. Compare an agent for everything with a router that sends only the odd cases to an agent.

  1. Agent for everything1,000 × 6 = 6,000

    Every email goes round the open loop.

  2. Route: label each email1,000 × 1 = 1,000

    One cheap call picks routine or odd.

  3. Routine: a fixed path900 × 1 = 900

    Code looks up the booking; one call writes the reply.

  4. Odd cases: the agent100 × 8 = 800

    The open loop, only where the path is open.

  5. Add up the mix1,000 + 900 + 800 = 2,700

    Fewer than half the calls.

Answer2,700 model calls a day instead of 6,000, and 9 emails in 10 take the same path every time.

Routing spends one call per email to save about five on most of them, and it makes most runs predictable enough to test like code. The agent's freedom goes only where it's needed.

Open-ended task

A task where you can't list the steps, or say how many there will be, before you see the input. That's the case Anthropic gives for an agent. Anything else gets a workflow, or one well-prompted call.

steps known in advance → workflow; open-ended → agent

So climb a rung at a time: one call, then a workflow, then an agent when the path is open, with the limits the rest of this module covers. Coding agents such as Claude Code and Codex are agents for this reason: each test result decides the next move.

Your turn

A support desk gets 500 tickets a day. 400 are password resets that a fixed path handles in 1 model call, and 100 need an agent that averages 10 calls. A labelling call sorts every ticket first. How many model calls a day?

Label all 500: 500 calls. The resets take 400 × 1 = 400, and the agent 100 × 10 = 1,000. 500 + 400 + 1,000 = 1,900. 1,400 forgets the labelling, 1,500 forgets the resets, and 5,000 sends every ticket to the agent.

Where you'll meet it

In interviews

Asked when you'd build an agent? Say: when the steps can't be listed before you see the input. Otherwise one call or a workflow is cheaper, faster and easier to test. Then give the reliability sum: at 99% a step, only 74% of 30-step runs come out clean, so long runs need checks that turn silent slips into visible ones.

On the job

Workflows are also easier to audit. A reviewer can read the path in your code. With an agent, the only record of what it decided is the trace of each run, which is why "Traces you can debug from" gets a lesson of its own. The two also mix: a workflow step can be a small agent with a cap of 8 tool calls.

The per-step bar for a clean run, in Python
target = 0.90                     # share of runs with no uncaught slip
for steps in (5, 10, 30, 60):
    need = target ** (1 / steps)  # each step must be at least this good
    print(f"{steps} steps: each step {need:.2%}")
print(f"30 steps at 99% each: {0.99 ** 30:.0%} of runs clean")
# 5 steps: each step 97.91%
# 10 steps: each step 98.95%
# 30 steps: each step 99.65%
# 60 steps: each step 99.82%
# 30 steps at 99% each: 74% of runs clean

Check yourself

Three questions from across the lesson. Try each one before you look back.

1

Four jobs land on your team. Which one would a fixed workflow handle worst?

Reproducing the bug can't be scripted: each log line or failed attempt decides what to try next, and nobody knows how many tries it will take. The other three run the same steps every time, so a chain or a single call does them more cheaply and more predictably.

2

A code assistant gets a change request. One call reads it and decides which files need edits, a separate call edits each of those files, and a last call checks the edits fit together. Which workflow shape is this?

One call plans subtasks nobody could list in advance, workers do them, and the results are combined. Routing picks one handler, a chain runs fixed steps, and voting asks the same question several times.

3

Which slip is most likely to spoil an agent's run without anyone noticing?

The first three are observations the model reads and can react to on its next turn, at the cost of a step. A wrong number copied into the answer raises no alarm, so it's the kind of slip that compounds.

What to remember

  1. 1Who picks the next step

    In a workflow your code picks each next step; in an agent the model does. The cancellation email took 2 calls along a fixed path and 6 as an agent.

  2. 2Five shapes of workflow

    Chaining, routing and voting fix their number of calls (2, 2 and 3 in the example); orchestrator-workers and evaluator-optimizer let a plan or a grade decide it, so cap them.

  3. 3Small slips multiply

    Unseen slips multiply: at 99% a step, only 74% of 30-step runs come out clean, and 90% needs 99.65% a step.

  4. 4Choosing for the task

    If you can write the steps down before you see the input, use a workflow, and route only the open-ended cases to an agent: 2,700 calls a day instead of 6,000.

Recap and going further

The lesson on one page

Workflow
  • Your code fixes the path
  • The model does the work inside each step
  • Same calls and cost on every run
Agent
  • The model picks each next step
  • Path and length change with the input
  • Needs limits, traces and checks
Five workflow shapes
  • Chain, route, run in parallel
  • Orchestrator-workers: a plan picks the subtasks
  • Evaluator-optimizer: write and grade in rounds
Who chooses the next step
Why long runs fail
  • Unseen slips multiply: 99% a step, 74% over 30
  • 90% over 30 steps needs 99.65% a step
  • A slip the agent can see costs a step
Choosing
  • Can you write the steps down first?
  • One call, then a workflow, then an agent
  • Route only the odd cases to an agent

Try this

Handle the same emails both ways

Write ten realistic emails to a hotel booking desk: date changes, refunds, a vague complaint, one in another language. Handle them first with a two-call workflow (label the email, then a reply prompt with the booking pasted in), then with an agent that has the same lookups as tools and a limit of 8 steps. Fake the booking data in plain Python and log every model call.

You need: Python and an API key for any model with tool calling.

Look for

  • How many model calls each email took, both ways.
  • Which emails the workflow got wrong, and whether the agent did better on exactly those.
  • How much the agent's call count changes between runs of the same email.
  • Whether the agent ever took an action you'd want a person to approve first.

The words, in plain language

Workflow and agent
A workflow strings model calls and tools along a path written in your code. An agent lets the model choose each next step in a loop. Anthropic's "Building effective agents" (2024) calls both agentic systems.
The five workflow shapes
Prompt chaining feeds each call's output to the next. Routing labels the input and sends it to one handler. Parallelization runs calls at once, on slices or as votes. Orchestrator-workers lets one call plan the subtasks. Evaluator-optimizer loops a writer and a grader.
Compounding errors
When a run succeeds only if every step does, its chance of success is the product of the steps' chances. Small error rates per step grow into large failure rates over a long run.
Open-ended task
A task where you can't list the steps, or say how many there will be, before you see the input. That's the case Anthropic gives for an agent. Anything else gets a workflow, or one well-prompted call.

Agents overviewSpotted a mistake? Tell us.