Lesson 50.4 · 4 of 4 · 5 min read · Reviewed 24 Nov 2026
Worked decision examples
By the end, you can
- Work through architecture decisions for realistic scenarios.
- Justify a choice with constraints.
Five scenarios
| Scenario | Key constraint | Choice | Why |
|---|---|---|---|
| Extract fields from 10,000 invoices nightly | Fixed steps, cost | Workflow + Message Batches | Steps known; batch discount (68.4) |
| Support assistant that looks up orders and issues small refunds | Actions with risk | Single agent, refund rules enforced in code | Needs flexibility; risk handled by gates (50.3) |
| Research report across 40 sources | Breadth, context size | Supervisor + parallel research subagents | Parallel exploration, isolated contexts (49.1) |
| Code change across a large repo | Risk of a wrong approach | Single agent with plan mode and tests | Plan reviewed first; tests as ground truth (47.4) |
| FAQ bot over a 30-page handbook | Simplicity | Single call with the handbook, cached | Fits in context; caching cuts cost (50.1) |
A decision path
Are the steps known in advance? yes -> workflow
Does it need to adapt to what it finds? yes -> single agent
Is the work broad and parallel, or too big
for one context? yes -> supervisor + workers
Do any actions carry real risk? add gates in code and human approval
Say what would change your mind
Good architecture answers include a trigger: “If evals show the single agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. misses sources on broad questions, move to a supervisor with research workers.”
Key points
- Start from the task's shape: fixed steps, open-ended investigation, or broad parallel exploration.
- Then apply constraints: latency, cost, risk of actions, and need for human review.
- Choose the simplest architecture that fits, and say what would make you change it.
- Exam scenarios usually hinge on one constraint; find it first.
Write architecture decision records
Turn a task's shape and key constraint into a recorded choice with a reason and a revisit trigger.
You will have: A choose() function and four one-line decision records.
Steps
- Run the starter: every scenario gets the same answer with no reason.
- For each scenario, name the one constraint that decides it.
- Write choose() so it returns the architecture, the reason and what would change your mind.
- Add a fifth scenario of your own and check the output makes sense.
Done when
- The invoice job gets Workflow + batch.
- The research report gets Supervisor + parallel subagents.
- Every record has a 'Revisit if' clause.
Open in the Playground No API key needed.
Starter code (Python)
# Write a short architecture decision record for each scenario.
SCENARIOS = [
{"name": "Nightly invoice extraction", "steps_fixed": True, "open_ended": False, "sources": 1, "risky_actions": False, "fits_context": True, "someone_waits": False},
{"name": "Support agent with small refunds", "steps_fixed": False, "open_ended": True, "sources": 2, "risky_actions": True, "fits_context": True, "someone_waits": True},
{"name": "Research report across 40 sources", "steps_fixed": False, "open_ended": True, "sources": 40, "risky_actions": False, "fits_context": False, "someone_waits": False},
{"name": "FAQ bot over a 30-page handbook", "steps_fixed": True, "open_ended": False, "sources": 1, "risky_actions": False, "fits_context": True, "someone_waits": True},
]
def choose(s):
"""Return (architecture, why, what would change my mind)."""
# TODO: fixed steps and nobody waiting -> workflow + batch
# TODO: fixed steps, fits in context, someone waiting -> single call, cached
# TODO: open-ended and many sources -> supervisor + parallel subagents
# TODO: open-ended with risky actions -> single agent, rules enforced in code
return ("single agent", "default", "nothing")
for s in SCENARIOS:
arch, why, change = choose(s)
print(f"{s['name']}: {arch}. Why: {why}. Revisit if: {change}.")
Show a solution
# Write a short architecture decision record for each scenario.
SCENARIOS = [
{"name": "Nightly invoice extraction", "steps_fixed": True, "open_ended": False, "sources": 1, "risky_actions": False, "fits_context": True, "someone_waits": False},
{"name": "Support agent with small refunds", "steps_fixed": False, "open_ended": True, "sources": 2, "risky_actions": True, "fits_context": True, "someone_waits": True},
{"name": "Research report across 40 sources", "steps_fixed": False, "open_ended": True, "sources": 40, "risky_actions": False, "fits_context": False, "someone_waits": False},
{"name": "FAQ bot over a 30-page handbook", "steps_fixed": True, "open_ended": False, "sources": 1, "risky_actions": False, "fits_context": True, "someone_waits": True},
]
def choose(s):
"""Return (architecture, why, what would change my mind)."""
if s["steps_fixed"] and not s["someone_waits"]:
return ("Workflow + batch", "steps are known and nobody waits, so cost is the constraint", "results are needed within minutes")
if s["steps_fixed"] and s["fits_context"]:
return ("Single call, cached", "everything fits in one prompt", "the source outgrows the context window")
if s["open_ended"] and s["sources"] > 10:
return ("Supervisor + parallel subagents", "breadth and context size", "the sources shrink to a handful")
if s["open_ended"] and s["risky_actions"]:
return ("Single agent, rules enforced in code", "needs flexibility; risk is handled by gates", "actions become irreversible at scale")
return ("Single agent", "open-ended but small", "the steps settle into a fixed pattern")
for s in SCENARIOS:
arch, why, change = choose(s)
print(f"{s['name']}: {arch}. Why: {why}. Revisit if: {change}.")
Finished the chapter? Take the chapter check.