← Back to the course home

👯 The five agent patterns

Every pattern is the same think→act→observe loop, wrapped differently — drawn twice: the numbered flow and the sequence diagram. Companion to lesson 08 — which also covers pattern zero: no agent at all 🙅.

1 🧍 The solo doer — one loop, one belt

Our agent.py: goal in, loop runs, reads flow, the write gates, outcome + log out.

The flow, numbered:

📋 goalone errand1🔁 the loopthink·act·observe2🧰 the beltlookup·calc·write🚧3✅ outcome+ full log 🧾4agent/agent.py IS this pattern — most real value ships in this shape

The sequence, message by message:

🧑 user🧍 agent🧰 toolsgoal: pizzas + save the plan1lookup / calc — reads flow2facts → pad3🚧 'write the note?' — gate4✓ allow5write_note6✅ done: 8 pizzas, plan saved7

💡 When it pays for itself: almost always — start here and only add structure when the task proves it needs it.

2 🗺️ Planner + executor — structure beats heroics

Decompose first, then work the checklist; the plan survives any single item failing.

The flow, numbered:

🗺️ plannerbreaks the project down1📋 checklist1 research · 2 draft · 3 cite2🧍 executor(s)work item by item3✅ assembled result4the to-do list from lesson 04, promoted to a first-class artifact

The sequence, message by message:

🧑 user🗺️ planner🧍 executor🧰 tools'research report on X'1THINK: decompose into 3 items2item 1: gather sources3search / read4sources → pad5item 1 done (artifact!)6…items 2 and 3 the same way — plan survives any single item failing…assembled report 📋7

💡 When it pays for itself: long or multi-part tasks where a raw loop drifts (L06 #4) or overflows the desk (L04).

3 🧑‍🏫 The critic loop — generate, grade, fix

A writer drafts; a merciless grader (best: actual tests) bounces it back until green.

The flow, numbered:

✍️ writerdrafts the code1🧑‍🏫 criticruns the TESTS (ground truth)2❌ feedbackwhat failed, exactly3✅ pass → ship4the best critics are merciless and mechanical: test runners, compilers, linters

The sequence, message by message:

✍️ writer🧑‍🏫 critic🧪 testsdraft v11run the suite22 failures, with tracebacks3feedback: exact failures4THINK: fix both5draft v26run again7all green ✅8pass — ship it9

💡 When it pays for itself: quality-critical output with a checkable definition of good — code, citations, structured data.

4 🚧 Human-in-the-loop — drafts flow, signatures gate

The agent does ALL the preparation; a person owns the one irreversible click.

The flow, numbered:

🧍 agent preparesdiff · summary · risks1🚧 human reviewsthe ONE irreversible step2✓ approve3🚀 executedeploy · send · pay4drafts flow, signatures gate — the pattern civilization runs on (see also: ArgoCD's sync button)

The sequence, message by message:

🧍 agent🏫 host🧑 human🌍 worldprepare: diff, tests, rollback plan1proposes deploy(v2)2🚧 shows the FULL change: 'allow?'3✓ (or edit, or deny)4execute the deploy5healthy ✅6proceed7report + log link 🧾8

💡 When it pays for itself: anything touching production, money, or other people — always, not optionally.

5 👯 The team — parallel work, checkable handoffs

Researcher, writer, checker — each its own loop; a foreman owns the single output.

The flow, numbered:

👷 foremanowns the outcome1🔎 researchergathers facts2✍️ writerdrafts from facts3🧐 checkerverifies claims4✅ one responsible outputcheckable artifacts at every handoff5powerful for parallel work — and it multiplies cost + compounding, so the foreman is not optional

The sequence, message by message:

👷 foreman🔎 researcher✍️ writer🧐 checkersubtask: facts on X (with sources)1facts.json 📄 — an artifact, not vibes2draft from facts.json ONLY3draft.md4verify every claim vs sources52 claims unsupported ❌6fix or cut those two7draft v28ship — one owner, one output ✅9

💡 When it pays for itself: genuinely parallel workstreams; skip it until the solo + critic combo actually falls short.