// Capstone · assemble three patterns
Capstone: refund with judgment
This capstone combines three patterns — not fifteen diagrams taped together. Build a stub support flow that prepares a refund reply, critiques it, and waits for a human before money moves.
// Warm-up · mixed practice
Which pattern fits?
Eight questions, mixed across all three tiers on purpose, so there is no tier label to lean on. Pick the pattern each scenario needs, then check it. Nothing is saved.
0 correct · 0 of 8 answered
// Pattern stack
What each pattern owns
- Orchestrator-Subagent
Dispatch research and draft specialists. The orchestrator only merges — it does not write the refund reply itself.
- Critic-Actor
A dedicated critic scores the merged draft against a refund rubric (no invented amounts, clear next step). Pass|revise with a retry budget of 2.
- HITL
Before any `execute_refund` stub runs, pause for human approve|reject|edit. No approval token → no side effect.
// Assembly sketch
One pipeline, three contracts
A support ticket goes to an Orchestrator, which calls a research stub and a draft stub and merges their output into a proposal. A Critic scores it with a rubric; on revise, the draft goes back to the actor (the draft stub) for at most two revisions. On pass, or when it needs a human, a HITL gate waits for approve, reject or edit. Only on approve does the execute_refund stub run, and then the flow is done.
Keep each part's job separate: the orchestrator delegates, the critic scores, the human approves. Then you can swap any stub for a real tool later without changing the others.
// Mini-project
Stub runner checklist
Orchestrator + critic + HITL stubs · no real money
Ship a demo script that proves the gate order. Stubs are enough; live models are optional later.
- Accept a canned support ticket that implies a possible refund.
- Orchestrator delegates `research_policy` and `draft_reply` stubs; merge into one proposal JSON.
- Critic scores the proposal; on revise, feed notes as data and allow ≤2 actor retries.
- On critic pass (or retries exhausted with status needs_human), call `request_approval`.
- Stub human: edit amount once, then approve. Only then call `execute_refund`.
- Log the chain: delegate → critic rounds → approval id → execute. Assert execute never precedes approval.
// Done when
You're done when
- One command runs the whole flow on stubs, with no real money, model or API.
- The log shows the chain in order: delegate → critic rounds → approval id → execute.
- A test proves `execute_refund` is called zero times before an approval exists.
- If the critic keeps saying revise, the actor revises at most twice, then the proposal goes to the human gate marked needs_human.
- Rejecting at the human gate means no refund runs.
- Editing the amount at the gate means the refund uses the edited amount.
- The reply text comes from the draft stub, never from the orchestrator itself.
// Failure mode
What usually breaks
Symptom: The orchestrator drafts, the critic is skipped, and a “preview” path calls execute without an approval token.
Fix: Stop the run if the critic result (a pass or a needs_human hand-off) or the approval id is missing. Tests should assert execute runs zero times until both gates clear.
// Reflect
One question
Which irreversible action in your own stack still has a specialist — but no critic and no human gate?
Sources
- Anthropic, “Building effective agents” (2024)
- Anthropic, “How we built our multi-agent research system” (2025)
- Yao et al., “ReAct: Synergizing Reasoning and Acting in Language Models” (2022)
- LangChain, “Plan-and-Execute Agents”
- LangChain, Build a personal assistant with subagents (supervisor tutorial)
- Dean & Ghemawat, “MapReduce: Simplified Data Processing on Large Clusters” (OSDI 2004)
- Amazon Builders’ Library (AWS Builder Center), “Timeouts, retries and backoff with jitter”
- Anthropic, API errors
- LangGraph, Interrupts (human-in-the-loop)
- OpenAI Agents SDK, Human-in-the-loop