Contents
What to cover
Sketch your own design first. A complete answer has these parts; the notes say what each should settle.
- Requirementswhich intents are in scope first; action risk levels; regulatory constraints (Consumer Duty, vulnerable customers, complaints); current handle time and volumes; channels; languages
- Estimates
- API
- Data model
- Architectureintent triage (respond / hand off / close); intent-gated context (transactions, account state); SME-vetted knowledge base retrieval; process/runbook-following; tools with scoped permissions and a deterministic policy engine (limits, eligibility); input/output guardrails (compliance, hallucination, PII, vulnerability); human handoff with summary; audit log; offline golden set + replays + simulated users; online QA sampling
- Deep diveshow do you stop a prompt-injected message from triggering a refund?; How do you decide when to stop human review of every message?; How do you evaluate an action-taking agent offline?
- Trade-offsautonomy vs review cost (progressive autonomy); small fast models for triage vs larger models for resolution; strict guardrails vs over-refusal; latency of checks vs safety
- Evaluationbusiness rules enforced outside the model; measured path to autonomy; vulnerable-customer escalation; component and end-to-end evals; incident loop that fixes the knowledge base quickly
Reference design
One way to answer it, part by part. Open a part once you have your own version of it.
Requirements
Scope first (confirm with ops)
- Launch intents: card lost/stolen/frozen, “what is this payment?”, balance and statement questions, starting a card dispute, app how-to. These are high-volume and mostly low-risk.
- Out of scope at launch, always to humans: fraud and scam victims, complaints, bereavement, financial difficulty, account closure, changes to personal details.
- Action risk levels: L0 answer from knowledge base; L1 read the customer’s own data; L2 protective and reversible (freeze/unfreeze card) — autonomous; L3 money-affecting (start a dispute or refund claim) — customer confirmation plus policy check; L4 irreversible or high-risk — never by the agent.
- Regulation: FCA Consumer Duty (act in good faith, avoid foreseeable harm, enable customers to pursue their financial objectives; the consumer-understanding and consumer-support outcomes apply directly to chat), vulnerable-customer guidance (FG21/1), complaint handling under DISP (a complaint must be recognised and logged even mid-chat), UK GDPR, record keeping for audit.
- Volumes and handle time: assume 40k chats/day, ~8 customer messages each, 12-minute average human handle time, evening peak 3× the hourly average.
- Channels: authenticated in-app chat first; email later; voice out of scope.
- Languages: English at launch (Welsh on request); detect other languages and route to humans.
- Success: containment without repeat contact, CSAT at least equal to humans, zero critical errors on money actions.
Estimates
CalculatorLatency budget for a first reply
- Total first-reply budget
- 1.9 s
- Headroom under target
- 1.1 s
Total first-reply budget = (max(Input guardrails, Triage) + Context fetch + Output checks) ÷ 1000 + Resolver first token = 1.9 s
Headroom under target = First reply target − Total first-reply budget = 1.1 s
| Case | Input guardrails (ms) | Triage (ms) | Context fetch (ms) | Resolver first token (s) | Output checks (ms) | First reply target (s) | Total first-reply budget | Headroom under target |
|---|---|---|---|---|---|---|---|---|
| Page budget | 150 | 300 | 200 | 1 | 400 | 3 | 1.9 s | 1.1 s |
- Turns: 40k chats × 8 = 320k customer turns/day; peak hour ≈ 320k / 24 × 3 ≈ 40k turns/h ≈ 11 turns/s.
- LLM calls: per turn one small-model triage call plus ~2 resolver calls (tool call, reply) → 320k × 3 ≈ ~1M model calls/day, plus guardrail classifiers.
- Tokens: resolver context ≈ 6k tokens per call (policy + runbook + intent-gated account context + history), output ≈ 300 tokens per turn. 320k turns × 2 resolver calls × 6k ≈ 3.8B input + 96M output tokens/day. At an assumed $3/M in, $15/M out: $11.5k + $1.4k ≈ $12.9k/day. Caching the ~4k-token static prefix at ~10% of the input price bills each call as 2k + 0.4k = 2.4k full-price tokens, a 60% cut → $4.6k + $1.4k ≈ ~$6k/day, ~15 cents per conversation.
- Human baseline: 40k × 12 min = 8,000 agent-hours/day. At ~£25/hour loaded that is £200k/day; 40% containment saves ~£80k/day, so LLM spend is not the binding constraint — error cost is.
- Latency: first reply p95 < 3 s; budget: input guardrails 150 ms (parallel), triage 300 ms, context fetch 200 ms, resolver first token 1 s, output checks 400 ms. Tool calls to core banking ≤ 500 ms p95.
- Audit: ~1M tool and model events/day × ~5 KB ≈ 5 GB/day, retained for years.
API
POST /v1/conversations → {conversation_id}
POST /v1/conversations/{id}/messages {text, attachments[]}
→ stream: message | action_proposed {action_id, summary, params}
| action_result {action_id, status} | handoff {queue, eta}
POST /v1/actions/{action_id}/confirm (sent by the app UI button, not by chat text)
Tools exposed to the model (all via a tool gateway; customer identity is bound from the authenticated session, never from model arguments):
search_kb(query, intent) → vetted snippets with article ids
get_transactions(from, to, merchant?, amount?) → list (scoped to session customer)
get_card_state(card_id)
freeze_card(card_id, reason, idempotency_key) → policy: allowed autonomously
start_dispute(transaction_id, reason_code, idempotency_key)
→ policy: eligibility + needs confirm token
handoff(queue, summary, priority, flags[]) → human queue
Every call returns structured data; the policy engine returns allow | needs_confirmation | deny(reason) before any side effect.
Data model
- Conversation: id, customer_id, channel, intent(s), status (bot | human | closed), autonomy stage, outcome, CSAT.
- Message: id, role, text, model and prompt versions, guardrail verdicts.
- ToolCall (append-only audit): id, conversation_id, tool, arguments, policy decision and rule ids, confirmation token, result, latency, idempotency key.
- PolicyRule: versioned deterministic rules (dispute window, amount limits, eligibility, rate limits per customer), owned by ops/risk, not prompts.
- KBArticle: id, version, SME owner, review-by date, intent tags, approved text; retrieval only from approved versions.
- Handoff: queue, summary, flags (vulnerability, complaint), priority, assigned agent, outcome.
- VulnerabilityFlag: minimal, special-category data with restricted access and purpose limits.
- EvalCase: transcript or scenario, bank-state fixture, expected tool calls and end state, grader config.
Storage: Postgres for conversations and policy; immutable log store for audit (WORM bucket); vector + BM25 index over approved KB versions.
Architecture
Flow · 5 stepsRequest path through the customer-operations agent
- Request arrives The app sends a message; the gateway runs triage and input checks in parallel.
- Route Triage routes respond to the resolver or hand off; guardrail flags feed the hand-off route.
- Resolve The resolver loads intent-gated context and KB runbooks, then calls tools through the gateway.
- Policy decides The policy engine allows safe calls to core banking; money-affecting actions return needs_confirmation for the in-app card.
- Reply or hand off The drafted reply passes output guardrails and reaches the customer; hand-offs go to the human console.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Request arrives | The app sends a message; the gateway runs triage and input checks in parallel. |
| 2 | Route | Triage routes respond to the resolver or hand off; guardrail flags feed the hand-off route. |
| 3 | Resolve | The resolver loads intent-gated context and KB runbooks, then calls tools through the gateway. |
| 4 | Policy decides | The policy engine allows safe calls to core banking; money-affecting actions return needs_confirmation for the in-app card. |
| 5 | Reply or hand off | The drafted reply passes output guardrails and reaches the customer; hand-offs go to the human console. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| App chat | Client | in-app chat |
| Chat gateway | Ingress | session auth |
| Input guardrails | Ingress | PII, injection, vulnerability, complaint |
| Triage | Agent | small model: intent, risk |
| Resolver agent | Agent | larger model + runbook |
| Context + KB | Agent | intent-gated data + SME-vetted KB |
| Output guardrails | Agent | grounded, compliance, no PII |
| Human console | Agent | summary, facts, flags |
| Tool gateway | Actions | scoped tools, session-bound |
| Policy engine | Actions | allow / needs_confirmation / deny |
| Core banking | Actions | core banking |
Source: This page's text
App chat ─► Chat gateway (session auth) ─► Input guardrails (parallel):
PII, injection heuristics, vulnerability & complaint detectors
─► Triage (small model): intent, risk → respond | hand off | close
─► Resolver agent (larger model)
├─ intent-gated context loader (only data this intent needs)
├─ KB retrieval (SME-vetted runbooks) → follows runbook steps
└─ tools ─► Tool gateway ─► Policy engine (deterministic) ─► core banking
─► Output guardrails: grounded in tool results/KB, compliance phrasing,
no advice, no PII leakage, tone ─► customer
─► Handoff: human console with summary, facts, actions taken, flags
Audit log (every message, tool call, policy decision) · tracing · eval harness
QA sampling ─► reviewers ─► KB fixes + regression cases
The model proposes; the policy engine and UI confirmation decide. Money-affecting actions show a confirmation card rendered from structured parameters, so the customer sees what will actually happen, not model prose.
Deep dives
Stack · 4 layersProgressive autonomy stages per intent
Agent drafts; human sends.
Human approves drafts before sending.
Auto-send with 10% QA sampling.
Auto with 2% QA sampling.
Stopping a prompt-injected refund. Customer text and merchant descriptors are untrusted. The model can only call tools through the gateway, which binds the customer from the session and validates arguments. The policy engine checks deterministically: the transaction belongs to this customer, is within the dispute window, is not already disputed or refunded, and is under limits; per-customer rate limits apply. L3 actions need a confirm token minted only by a tap on the in-app card. So a fully jailbroken model can do nothing the customer could not do in the app themselves.
When to stop reviewing every message. Progressive autonomy per intent: shadow (agent drafts, human sends) → human approves drafts → auto-send with 10% QA sampling → auto with 2%. Promotion needs ≥ 3,000 conversations at the current stage with ≥ 95% drafts accepted unedited, CSAT and repeat-contact no worse than humans, and zero critical errors: 0 in 3,000 puts the 95% upper bound on the critical-error rate at ~0.1% (rule of three, 3/n). Automatic demotion on any critical error or metric breach.
Evaluating an action-taking agent offline. Replay historical chats against a sandboxed bank with state fixtures; add simulated customers (confused, vulnerable, adversarial) with goals. Grade tool calls and arguments exactly, final account state, policy compliance and handoff decisions in code; judge tone and clarity with a calibrated LLM judge. Run each scenario k times and report pass^k, because reliability matters more than best case.
Trade-offs
- Autonomy vs review cost: full review is safe but saves little; progressive autonomy per intent with measurable gates spends review where risk is.
- Small fast models for triage vs larger for resolution: a small model classifies intent and risk in ~300 ms for every turn; the larger model only runs once we know the turn is in scope. Cheaper and faster, but triage errors cascade, so evaluate triage recall on hand-off classes separately.
- Strict guardrails vs over-refusal: over-refusal is also a Consumer Duty failure (the customer is not helped). Track unnecessary hand-off rate alongside unsafe-response rate and set thresholds per intent.
- Latency of checks vs safety: run input checks in parallel with triage and output checks on the drafted reply; reserve slower LLM checks for money-affecting turns, where an extra second is acceptable.
- Retrieval-grounded KB vs fine-tuning: KB changes ship in minutes and are auditable; fine-tuning only for tone and format, never for policy facts.
Evaluation
- Business rules outside the model: policy engine with unit tests per rule; red-team suite of injection and social-engineering attempts must produce zero unauthorised actions.
- Measured path to autonomy: stage per intent recorded in config; promotion and demotion criteria as above; dashboards per intent.
- Vulnerable-customer escalation: labelled set of signals (bereavement, illness, financial hardship, coercion, distress); recall ≥ 95% at the chosen threshold; every flagged chat goes to a specialist queue; reviewed monthly with the vulnerability team.
- Component and end-to-end evals: triage accuracy, retrieval recall, tool-argument accuracy, guardrail precision/recall, plus end-to-end replays and simulated users with pass^k; a CI gate on every prompt, model or KB change.
- Online: containment, 7-day repeat contact, CSAT, complaint rate, time to resolution, critical error rate from QA samples, hand-off summary quality rated by agents.
- Incident loop: a wrong answer is tagged in QA, routed to the KB owner, fixed and republished within 24 hours, and the case added to the regression set; prompt or policy hotfixes go through the same CI gate.
What a strong design shows
- Ranks actions by risk and enforces eligibility, limits and identity in deterministic code, with UI confirmation for money movement — the model only proposes.
- Names the UK regulatory frame (Consumer Duty, vulnerable customers, complaint recognition) and turns it into concrete routing rules.
- Describes progressive autonomy per intent with numeric promotion and demotion criteria.
- Evaluates offline with replays, state fixtures, simulated users and repeated trials, not just a static Q&A set.
- Closes the loop: QA findings fix the knowledge base within a day and become regression tests.