learn-ai-agents-with-phoebe / Builder session 3 of 10
Learn AI Agents with Phoebe · Builder track · Session 3 of 10

The five workflow patterns

Before you give a model the steering wheel, learn the five ways to keep it. Anthropic's essay names exactly five workflow patterns - prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer - each a predefined code path that uses LLMs without letting one direct the show. Tonight you meet all five as pictures, then build three of them on Daybreak in plain Python. The punchline the whole industry keeps relearning: for most tasks, a boring fixed path beats a clever agent - and knowing all five is what makes "do we even need an agent?" an engineering question instead of a vibe.

🟡 Medium Builder track · practitioners Python 45 min
0-3 · Welcome 3-18 · The catalog 18-42 · Build-along: three patterns on Daybreak 42-45 · Q&A
Part 1 · covers Anthropic "Building Effective Agents" (all 5 patterns), Ng M2/M5

The catalog 15 min live

Five shapes, one rule: in every pattern below, your code fixes the path and the model fills in the steps. That is Anthropic's definition of a workflow - "LLMs and tools orchestrated through predefined code paths" - and the exact opposite of b2's loop, where the model chose its own next move. Learn the shapes first; the code in Part 2 will read itself.

1 · Prompt chaining numbers draft polish 2 · Routing ticket in refund handler subs handler general handler 3 · Parallelization fan out Jan + Feb Mar + Apr May + Jun merge 4 · Orchestrator-workers orchestrator worker: sales worker: subs worker: tickets results return 5 · Evaluator-optimizer generator evaluator feedback - loop until pass All five are workflows - code fixes the path, the model fills in steps; an agent chooses its own path.
🔍 Click to zoom - Anthropic's five workflow patterns, one shape per row
LivePrompt chaining - a fixed sequence2 min▶

What it is: decompose a task into fixed steps, each LLM call feeding the next - optionally with a code check ("gate") between steps.

When it wins: the task cleanly splits into stages and you trade a little latency for a lot of accuracy per stage.

Daybreak: the monthly report pipeline - pull the numbers → draft the report → polish for the founder. Three calls, one path, no surprises. You build it in Part 2.

LiveRouting - a classifier picks the branch2 min▶

What it is: one cheap classification call sorts the input, then code dispatches to a specialized handler - separate prompts, even separate models per branch.

When it wins: distinct input categories that are handled better apart than by one prompt trying to serve them all.

Daybreak: ticket triage - classify each support ticket as refund, subscription, or general, then dispatch to that branch's handler. Also in Part 2.

LiveParallelization - fan out, then merge2 min▶

What it is: run independent LLM calls simultaneously and aggregate the outputs - either sectioning (split the work) or voting (same work, multiple attempts).

When it wins: the subtasks do not depend on each other, so waiting in sequence is pure wasted latency.

Daybreak: query all six months of 2026 revenue at once, then one merge call summarizes the half year. Sketched in Part 2 with asyncio.gather.

LiveOrchestrator-workers - a hub delegates2 min▶

What it is: a central LLM breaks the task into subtasks it could not have listed in advance, delegates each to a worker call, and synthesizes the results.

When it wins: you cannot predict the subtasks up front - the decomposition itself needs the model's judgment.

Daybreak: the March-dip diagnosis - "revenue fell, find out why" fans into sales, subscription, and refund investigations, then one synthesis. Tonight's demo shows the agent version of exactly this shape.

LiveEvaluator-optimizer - generate, judge, loop2 min▶

What it is: one LLM generates, another evaluates against explicit criteria and returns feedback; the pair loops until the evaluator passes it (or a max-rounds guard trips).

When it wins: you can state clear evaluation criteria, and iterative critique measurably improves the output.

Daybreak: the founder's report drafted, then judged against a checklist - numbers cited? refunds excluded? one concrete action? - and redrafted until it passes.

Reflection and evaluator-optimizer are the same inner move Reflection (Ng) Evaluator-optimizer Critique, revise Same idea, two vocabularies - now you speak both. The evaluator turned inward is reflection.
🔍 Click to zoom - two names, one move: generate, then critique your own draft
Ng's map Andrew Ng's agentic-canon Reflection pattern is exactly the evaluator-optimizer's inner move: the model critiques and revises its own output. Same idea, two vocabularies - now you speak both.
Part 2 · covers Academy Agents-and-Workflows lessons (chaining, routing, parallelization)

Build-along: three patterns on Daybreak ★ 18 min · type along

All three builds share one helper - a single plain call, no tools, no loop:

import anthropic

client = anthropic.Anthropic()

def ask(prompt: str) -> str:
    response = client.messages.create(
        model="claude-opus-5", max_tokens=1024,
        messages=[{"role": "user", "content": prompt}],
    )
    return response.content[0].text

1 · Prompt chaining - the monthly report as three sequential calls, each output piped into the next. The tool functions are b2's Daybreak toolbox:

def chain_monthly_report(month: str) -> str:
    facts = (query_sales(month) + "\n" + top_products()
             + "\n" + subscription_status())
    numbers = ask("Summarize these raw Daybreak numbers as bullet points, "
                  "refunds excluded from revenue:\n" + facts)
    draft = ask(f"Write the {month} ops report for the founder "
                f"from these numbers ONLY:\n{numbers}")
    return ask("Polish this report: short, concrete, exactly one "
               "action item for next month.\n" + draft)

2 · Routing - one classifier call, then a plain dict dispatch. The model labels; your code branches:

HANDLERS = {"refund": handle_refund,
            "subscription": handle_subscription,
            "general": handle_general}

def route_ticket(ticket: str) -> str:
    label = ask(
        "Classify this Daybreak support ticket. Reply with exactly one "
        "word - refund, subscription, or general:\n" + ticket
    ).strip().lower()
    handler = HANDLERS.get(label, handle_general)   # safe fallback
    return handler(ticket)

3 · Parallelization - six independent month lookups have no business waiting for each other. Fan out with asyncio, then one merge call:

import asyncio

async def h1_summary() -> str:
    months = [f"2026-0{m}" for m in range(1, 7)]     # Jan..Jun
    results = await asyncio.gather(
        *(fetch_sales(month) for month in months)    # async ask() per month
    )
    return await ask_async("Summarize H1 2026 for the founder "
                           "from these six month reports:\n"
                           + "\n".join(results))
These are workflows, not agents - and that is the point Notice what is missing: the while loop. b2's agent inspected stop_reason and chose its own next step; here every path is decided before the first token streams - chaining always runs three calls, routing always classifies then dispatches, parallelization always fans out six and merges. Predefined paths are cheaper, testable, and debuggable. Anthropic's rule: start here, and slide toward the agent loop only when the task demonstrably will not fit a fixed path.
Self-studyThe two patterns we did not build tonight3 min read▶
  • Orchestrator-workers is a chaining-shaped skeleton where the model writes the plan: one call produces the subtask list, code runs a worker call per subtask, one call synthesizes. You will build it properly in b6, where the workers become full subagents.
  • Evaluator-optimizer is a two-call loop with a max-rounds guard: generate, evaluate against a checklist, feed the critique back, repeat until the evaluator says pass. It returns in b5 as the Reflection pattern and again in b8, where the evaluator grows into a real LLM-judge grader.

Homework asks you to sketch the orchestrator version of tonight's report chain - one prompt, model-written plan - and compare it honestly against the fixed chain.

Demo

Orchestrator-thinking, live: the March-dip diagnosis ★ 8 min · everyone runs it

The founder asks: "Why did March revenue dip?" Below, the Daybreak agent runs the diagnosis with tools, memory, and planning on. Watch the plan step closely - the model decomposes the question into sub-investigations (sales by month, refunds, subscription changes) before touching a tool. That is orchestrator-thinking, live. The answer it assembles: February $271 → March $150, one refund (order 1017), and Liam Ford's Midnight Espresso subscription cancelled 2026-03-10.

Step to the 🧠 plan step and read the decomposition. That plan is what b5 teaches the model to write well - and a FIXED version of that same plan is exactly what a workflow hard-codes.

Watch the plan execute: each sub-investigation is a tool call whose 📦 result feeds the next decision - orchestrator-workers with one model playing every part.

Ask the b3 question: if the founder wants this diagnosis EVERY month, would you keep the agent - or freeze tonight's plan into a chain? Cheaper, testable, boring. Boring is a feature.

Freeze the shape, or let the model decide? Same shape, every time? yes no Freeze it into a workflow Cheaper, testable, boring Keep it an agent Model decomposes at runtime If the founder wants this diagnosis every month, freeze tonight's plan. Boring is a feature.
🔍 Click to zoom - repeats the same way every time - freeze it, otherwise keep the agent
How to read every agent demo in this course 👤 user · 🧠 model reasoning · 🔧 tool call · 📦 tool result · 🛡 guardrail · 💬 final answer. The model's words are a scripted teaching simulation replaying the characteristic behaviors; every number in a 📦 step is genuinely computed from the embedded Daybreak data.
Homework

Try it yourself - this week ◐ 30-40 min total

Source material

Official sources covered

Certificates, videos, and graded assessments stay on the official sites (linked each session). This page covers:

✓Anthropic "Building Effective Agents" - the five workflow patternsPrompt chaining · routing · parallelization · orchestrator-workers · evaluator-optimizer
✓Anthropic Academy - Agents and Workflows sectionParallelization, chaining, and routing lessons - built here on Daybreak
◐DeepLearning.AI "Agentic AI" (Ng) - Modules 2 + 5Reflection (= evaluator-optimizer's inner move) + Planning; planning lands in b5
◐DLAI "Agentic Design Patterns" (AutoGen)Same 4-pattern canon (Reflection · Tool Use · Planning · Multi-Agent) from another stack
Check yourself

Three questions before you go 🎯 ◐ 90 seconds

1 · Six independent month lookups, then one combined summary. Which pattern?

The lookups do not depend on each other, so running them in sequence is pure wasted latency. Chaining is for steps that feed each other; routing is for sorting different KINDS of input, not identical independent work.

2 · Which Anthropic pattern is Andrew Ng's Reflection pattern the inner move of?

Reflection = generate, critique against criteria, revise. That critique-and-loop is exactly the evaluator half of evaluator-optimizer. Two vendor vocabularies, one idea - and in b8 the evaluator becomes a formal LLM-judge grader.

3 · What separates all five of tonight's patterns from b2's agent loop?

Anthropic's line: workflows orchestrate LLMs "through predefined code paths"; agents "dynamically direct their own processes." Workflows can make many calls and use tools freely - what they never do is let the model choose the route.

Builder session 3 cheat sheet · pin this

Prompt chainingFixed sequence, each call feeds the next. When the task splits into clean stages - Daybreak's numbers → draft → polish report.
RoutingClassify once, dispatch to a specialized handler. When input categories are handled better apart - ticket triage.
ParallelizationFan independent calls out, merge the results. When subtasks do not depend on each other - six months queried at once.
Orchestrator-workersA hub LLM writes the subtask list, delegates, synthesizes. When you cannot predict the decomposition up front - the dip diagnosis.
Evaluator-optimizerGenerate, judge against explicit criteria, loop until pass. When clear criteria exist and critique measurably helps - the report checklist.
Ng's mapReflection = evaluator-optimizer's inner move. Same canon as AutoGen's: Reflection · Tool Use · Planning · Multi-Agent.
The dividing lineWorkflows = predefined code paths; agents = the model directs its own process. Who chooses the next step is everything.
The ruleStart at the workflow end - cheaper, testable, boring. Slide toward the agent loop only when the task demonstrably demands it.