Capstone: support bot with RAG + tools
Implement one traceable happy path
One clean transaction through **POST /v1/support/turn** must match the oracle: order lookup returns status+policy cite; cross-customer order_id → deny+escalate.
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
Order the successful transaction
Code the narrow path that serves customer asking where order A12 is without leaking other customers' orders: accept → authorize/normalize → call dependency → validate → record. Keep stages named so a trace can show which boundary passed. Success must emit evidence useful to unauthorized_tool_calls == 0 and citation_rate ≥ 0.9, not only a 200 with prose. Predict the observable for POST /v1/support/turn before running: order lookup returns status+policy cite; cross-customer order_id → deny+escalate.
Read
Run with fakes first
Drive the path with recording fakes or local stubs. Assert call order and arguments. Idempotency keys or stable ids should keep retries from duplicating costly work where the product requires it. Product under test remains support API: versioned policy retrieval + scoped order tool + cited answer or escalate — resist adding unrelated features mid-path.
Read
Implementation artifact
const out = await turn({ sessionCustomer: "cust_7", text: "Where is order A12?" });
expect(out.citations).toContain("policy:shipping");
Read
Compare prediction to result
For Capstone: support bot with RAG + tools, paste the CLI/HTTP transcript beside your prediction for POST /v1/support/turn. If the oracle is unmet (order lookup returns status+policy cite; cross-customer order_id → deny+escalate), stop and debug this page; do not compensate with prompt folktales. Re-run once after a clean process start to catch hidden global state that would invalidate CAP-SUPPORT-TOOL-09.
Read
Stage depth
Performance sketch: measure local p95 for the fake-backed path so later regressions are obvious. Keep concurrency modest until failure-handling proves limits. Log a single structured event per success with request id, revision, and the evidence field behind unauthorized_tool_calls == 0 and citation_rate ≥ 0.9. Avoid hidden global caches in the happy path unless the lab is about caching — and even then key by tenant. If the path calls a model, pin model id in config and echo it in the response for auditability. Remember customer asking where order A12 is without leaking other customers' orders experiences wall-clock time, not your debugger’s single-step comfort.
Read
Field notes for `capstone-support-bot` / `happy-path`
Prefer explicit function names over a single god-object handleRequest. Thread a correlation id from ingress to the last log line. When streaming, define what partial failure means before coding. Snapshot one successful response body in fixtures after redaction. If the path writes to a queue, assert message attributes in the fake. Stop adding retries on this page; that is the next concern. 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. If you only have forty minutes, finish the fixture for model passes attacker order_id and tool executes before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.
Go deeper
Before you start
Why this matters
Without calling production, order the steps a single success takes for customer asking where order A12 is without leaking other customers' orders. Circle the first irreversible side effect. Your prediction should mention POST /v1/support/turn and the evidence field that proves order lookup returns status+policy cite; cross-customer order_id → deny+escalate.
This happy path is the spine of the capstone demo for customer asking where order A12 is without leaking other customers' orders.
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.