← All lessons Lesson 0006

Architecture

Two ways to build the program

This lesson is not a ChatGPT feature, and it is not a product named “agent workflow.” It is the first real design choice you make when you write software that calls an LLM: does your code already know the steps, or is your code a loop that lets the model pick the next tool?

What this is. Architecture for an app you ship — an invoice bot, a support bot, a coding agent at work. You are writing the program. The model is a function you call (lesson 0003). Tools are slips your code runs (lesson 0005).

What this is not. Training a model. A vendor menu item. “Agent workflow” as one mashed-together name — Anthropic keeps the two words apart on purpose. The runtime around the loop is the harness — lesson 0007.

  1. 1 · One callYour program: messages in, text out. Often enough.
  2. 2 · WorkflowYour program already lists the steps. Control flow is in source.
  3. 3 · AgentYour program is a while-loop. The model chooses the next tool until stop.

“Building your own agent” means writing that loop (later: wrapping it in a harness). A workflow is also something you build — it is just more prescribed.

Who owns control flow?

Anthropic’s definitions, used as the field’s split: a workflow orchestrates LLMs and tools through predefined code paths. An agent is a system where the LLM dynamically directs its own process and tool use. They call the pair agentic systems. Building effective agents

Two flowcharts. Left workflow: your code owns a straight path of LLM and tool steps. Right agent: your code is a loop; the model chooses tool or final text; stop if done or max steps. Caption: The model is a function you call.

Same tools as lesson 0005. Architecture = who decides the next call.

The two programs · pseudocode

# WORKFLOW — you already know the steps
a = llm("extract the order fields")
b = check_oven()                  # your code always does this next
c = llm("write the ticket", a, b)
return c

# AGENT — you do not know the steps
while steps < MAX:
    action = llm(messages, tools) # model: tool call or final text?
    if action is text:
        return action             # stop
    result = run(action)          # your code still runs the tool
    messages.append(result)       # paste back into RAM, loop

What this shows. In both programs you are the author. In a workflow the if/then is in your source. In an agent the if/then of “which tool next?” is inside the model; your source is the loop, the tool runner, and the stop. That is the whole architectural difference.

The muddy phrase “agent workflow”

People say it. Treat it as marketing fog. In this course:

Same idea, one kitchen example

If the flowchart is clear, you can skim this. It is only to make the two programs concrete.

Workflow · path known before the user arrives

userOne Margherita, as usual.
your code · always step 1
check_oven()
your code · always step 2
stretch_dough()
your code · always step 3
top({ "tomato": true, "basil": true })
your code · always step 4
bake({ "seconds": 90 })
returnMargherita up.

What this shows. Invoice pipelines, “always retrieve then answer,” onboarding checklists: the sequence does not change. The model may fill a step; it does not get to invent a new step.

Agent · path unknown until the model chooses

userUse up tonight’s walnuts. I trust you.
model chose tool 1
count_stock({ "item": "walnut" })
your code ran it
{ "handfuls": 3 }
model chose tool 2
check_oven()
your code ran it
{ "temp_c": 240 }
model chose tool 3
make_pizza({ "name": "walnut crumb" })
model returned text · your loop stopsWalnut crumb special is up.

What this shows. Open support tickets, “fix this repo,” research: you cannot list the tools in order ahead of time. You still run every tool. You still set MAX. Anthropic: that loop is an agent. It costs more turns; a bad tool call can poison the next one.

Kitchen metaphor of the same split: a straight four-station line versus a chef at a ticket wheel.

Metaphor only. The load-bearing picture is the flowchart and the two programs above.

Skill: name the architecture

Three requests into the same kitchen app. Watch whether your program is one call, a fixed sequence, or a loop.

Same app, three architectures

Which one to write

Anthropic’s rule is not “build an agent.” It is: start with the simplest program that works, and add a loop only when a fixed path cannot name the steps. For many apps that is still one LLM call plus retrieval. Workflows buy predictability. Agents buy flexibility and spend latency and money. Same essay, “When (and when not) to use agents.”

Write one call when

The answer is in the script, or a RAG paste is enough. No tools in a loop.

Write a workflow when

You can list the steps today: extract → lookup → draft. Same path every run.

Write an agent when

You cannot hardcode the steps, and you will accept extra calls plus a stop condition.

One toaster versus a full brigade making toast — do not wrap a one-call job in an agent loop.

An agent is a loop you must operate. Do not wrap a one-call job in that loop.

Three rungs: one call, workflow, agent. Climb only if the rung below fails.

Mission skill: defend this choice in a design review.

If you chose a workflow

Anthropic names five common shapes of predefined path. They are still workflows — you drew them. An agent is what you write when even these shapes cannot name the steps in advance.

Do not memorise implementations tonight. The load-bearing fact: those five still have control flow in your code. Frameworks (LangChain, Agent SDKs) can hide whether you wrote a path or a loop — Anthropic’s advice is to see the calls first.

Check

1. This lesson is about
2. In a workflow, the next step is chosen by
3. “Building an agent” means you write
4. Anthropic’s first move is

Primary source. The two definitions plus “When (and when not) to use agents” in Building effective agents. Skim the five workflow names. The three principles at the end (simplicity, show the plan, tool interface) hang on the harness — lesson 0007.

Card: two architectures.