Skip to content

// 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.

  1. 01Before a launch you need three checks that don’t depend on each other: a legal read of the copy, a broken-link scan and an accessibility scan. Then one go/no-go note. Which pattern fits?
  2. 02An agent drafts a goodwill credit for a customer’s account, and a critic already checks the draft. What must still happen before the credit is applied?
  3. 03A nightly report always runs the same steps: pull yesterday’s orders, total them by region, draft a summary, save it. Steps rarely fail. Which core loop fits?
  4. 04A product-description writer must reach at least 8 out of 10 from an automated grader, with at most three rounds. No person reviews it in the loop. Which pattern fits best?
  5. 05You have 400 customer reviews. You want the same “pull out the complaints” prompt run on each batch of 20, then one combined top-ten list. Which pattern fits?
  6. 06A support agent must find out why an order is stuck. Each lookup (order, then payment, then shipment) tells it which system to check next. Which pattern fits?
  7. 07One call to a partner API times out and then works on a later try. Another call fails with “permission denied”. What should the loop do?
  8. 08Two worker agents draft ticket replies. You need one coordinator that picks which worker handles each ticket and blocks any reply that promises a refund amount no tool returned. It must not write replies. Which pattern fits?

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.

  1. Accept a canned support ticket that implies a possible refund.
  2. Orchestrator delegates `research_policy` and `draft_reply` stubs; merge into one proposal JSON.
  3. Critic scores the proposal; on revise, feed notes as data and allow ≤2 actor retries.
  4. On critic pass (or retries exhausted with status needs_human), call `request_approval`.
  5. Stub human: edit amount once, then approve. Only then call `execute_refund`.
  6. 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