Capstone: support bot with RAG + tools
Define the service boundary and ship target
Ship a falsifiable slice of **support API: versioned policy retrieval + scoped order tool + cited answer or escalate** — success is order lookup returns status+policy cite; cross-customer order_id → deny+escalate, not a polished screenshot.
1Try it yourself
Playground
Support bot: RAG + tool
Retrieve policy text, optionally fetch live order status, then answer with citations.
User: Can I refund order #8821 on my annual plan?
- → Retrieve FAQ chunk
- ○ Call order lookup tool
- ○ Generate cited reply
2Learn the idea
Read
Name the operable slice
This lab builds support API: versioned policy retrieval + scoped order tool + cited answer or escalate. The human in the loop is customer asking where order A12 is without leaking other customers' orders. Scope is intentionally narrower than “make AI reliable”: you will prove one oracle — order lookup returns status+policy cite; cross-customer order_id → deny+escalate — and one invariant — tool args bind to session customer_id; refunds never auto-executed. Record non-goals in your notes so a later change cannot silently expand authority. The incident mnemonic for the chapter is CAP-SUPPORT-TOOL-09; design as if that ticket is already written and you are filling evidence.
Read
Write the acceptance contract
Turn the oracle into a table: input fixture, expected observable, prohibited side effect, owner, latency/cost ceiling. Separate model taste from software correctness — transport, auth, parsing, and termination must be deterministic even when generated text varies. Primary metric family: unauthorized_tool_calls == 0 and citation_rate ≥ 0.9. Averages without a denominator or revision label do not gate release. Fake external dependencies in unit tests; live calls wait until fakes pass.
Read
Implementation artifact
const tools = ["lookup_order", "escalate"] as const; // no refund_order
Read
Freeze the first red test
Before implementation, encode a failing check that would have caught model passes attacker order_id and tool executes. That failure is the pedagogical north star for later pages: contracts reject it, happy path never performs it, validation asserts it, failure-handling contains it, observability detects it, security-ops prevents privilege tricks around it, and mastery replays it in a drill. Endpoint under study: POST /v1/support/turn.
Read
Stage depth
Capacity note for planners: estimate peak demand on POST /v1/support/turn and the cost ceiling for a failed retry storm. Write the abort conditions — unbounded spend, cross-tenant leakage, or inability to roll back — before you enjoy the first green test. Prefer synthetic fixtures shaped like production over anonymized production dumps you cannot share in class. When you are tempted to widen scope, re-read the oracle (order lookup returns status+policy cite; cross-customer order_id → deny+escalate) and cut features that do not serve it. The teaching outcome is judgment under constraints: customer asking where order A12 is without leaking other customers' orders gets a trustworthy control, not a kitchen-sink framework. Keep the language of release decisions: promote, hold, or roll back — never “see if it gets better.”
Read
Field notes for `capstone-support-bot` / `lab-goal`
Decide what will live in version control on day one: fixtures, contract markdown, and a failing test name. Write the cost ceiling as a hard number with currency and period. If the lab involves clusters, name the non-prod context you will use and forbid prod kubecontexts in scripts. Capture the baseline metric once before changing code so later gains are comparative. Refuse tools that hide the request path behind magic macros until the oracle is green on fakes. Your README section for this page should be five lines or fewer and still falsifiable. In this chapter the product is support API: versioned policy retrieval + scoped order tool + cited answer or escalate, the human stakeholder is customer asking where order A12 is without leaking other customers' orders, and the incident id you design against is CAP-SUPPORT-TOOL-09. Re-state the oracle in your notes — order lookup returns status+policy cite; cross-customer order_id → deny+escalate — and keep the invariant visible: tool args bind to session customer_id; refunds never auto-executed. Track unauthorized_tool_calls == 0 and citation_rate ≥ 0.9 as the scoreboard. Surface under change control: POST /v1/support/turn.
Go deeper
Before you start
Why this matters
Write the single done-definition a reviewer would accept for Capstone: support bot with RAG + tools (CAP-SUPPORT-TOOL-09). Include the numeric gate hidden in this oracle: order lookup returns status+policy cite; cross-customer order_id → deny+escalate. Then name the fake success you refuse: a demo that ignores model passes attacker order_id and tool executes. Keep the sentence beside your editor; every later page should make this sentence easier to prove.
Across this capstone you will evolve one product narrative — support API: versioned policy retrieval + scoped order tool + cited answer or escalate — rather than eight disconnected exercises.
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.