Page 5 of 8~144 min topic

Capstone: support bot with RAG + tools

Design retries, degradation, and recovery

When model passes attacker order_id and tool executes, the system must degrade on purpose without widening blast radius.

~18 min this pageFailure handling

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?

  1. Retrieve FAQ chunk
  2. Call order lookup tool
  3. Generate cited reply

2Learn the idea

Read

Classify and bound retries

Map failure classes for POST /v1/support/turn: retryable vs fatal vs needs-human. Retries need budgets, jitter, and idempotency rules aligned to tool args bind to session customer_id; refunds never auto-executed. The chapter’s signature failure — model passes attacker order_id and tool executes — must take a deliberate branch, not a generic catch-all.

Read

Containment path

Implement the degrade/rollback/refuse behavior customer asking where order A12 is without leaking other customers' orders needs when CAP-SUPPORT-TOOL-09 repeats. Prefer scoped controls (one flag, one weight, one tenant, one secret version) over fleet-wide restarts. Preserve evidence; do not delete logs to “clean the demo.”

Read

Implementation artifact

if (args.customer_id !== session.customer_id) throw new SafeError("customer_mismatch");

Read

Verify harm reduction

After containment, check unauthorized_tool_calls == 0 and citation_rate ≥ 0.9 moves in the safe direction and watch for retry amplification. Write the stop condition that ends the incident response for this lab.

Read

Stage depth

Chaos note: inject only one fault class at a time and restore fixtures after. Watch for dual failures — dependency down and retry amplifier — which is how model passes attacker order_id and tool executes becomes an outage. Customer communication templates (even if only for the drill) beat silence. If you queue deferred work, define poison-message handling. Budget documents should state the maximum extra spend allowed during retries. Close the loop by linking the containment action to a dashboard panel for unauthorized_tool_calls == 0 and citation_rate ≥ 0.9.

Read

Field notes for `capstone-support-bot` / `failure-handling`

Draw a state diagram for degrade modes and put it in the repo as ASCII if needed. Cap concurrent retries across the process, not only per request. Ensure cancellation propagates to downstream HTTP clients. When failing closed, choose a user-visible message that does not leak internals. Practice the single command that flips the kill switch or weight to zero. After recovery, drain or inspect deferred work before declaring green. 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

Assume model passes attacker order_id and tool executes is happening right now. Write the first safe action, the signal that confirms containment, and the action you will not take (infinite retry, broad restart, deleting evidence). Tie the plan to invariant: tool args bind to session customer_id; refunds never auto-executed.

Capstone failure drills reuse CAP-SUPPORT-TOOL-09 as the story you tell in the ship review.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Are retry budgets explicit?
2. Is containment scoped?
3. Do you preserve evidence for CAP-SUPPORT-TOOL-09?

All responses are required.