RAG & Data Pipelines · 2 to 3 hours
Design a cited support assistant with measurable quality
Design a support assistant that answers from help articles with citations the customer may see, or hands off to a human. Turn its requirements into metrics, plan its evaluation set, keep it fresh through updates and deletion, and check its token, cost, and latency budgets.
3 h
Used in interview rounds:
AI System Design (Medium)Overview
Design a retrieval-grounded support assistant the way a Medium AI system design round expects. Start from requirements and success metrics, then build the paths, citations, evaluation, lifecycle, and budgets around them. You practice on a fictional help center with plan-restricted articles, internal runbooks, and fixed budget figures.
Study time: 2 to 3 hours
Interview format: AI system design round, 45 to 60 minutes
By the end you can
- Turn a support assistant's requirements into success metrics, each with a denominator and a target
- Design ingestion and query paths that check access when evidence is selected and when a citation is rendered
- Build citations from a request-local label map and trusted source records, never from links the model writes
- Plan an evaluation set with answerable, multi-passage, unanswerable, restricted, and stale cases, and state its gate before reading results
- Keep the index, the answer cache, and old citations fresh through updates and deletion
- Compute token, cost, and latency budgets, and roll out a prompt change with a canary and rollback
Prerequisites
Helpful background: Familiarity with the ingestion and query paths of a RAG system and with streamed model responses helps.
This topic covers ingestion, grounding, citations, and the document lifecycle. Embeddings & Retrieval covers how candidates are found and ranked.
Start from requirements and success metrics
Begin with the users, what a good outcome looks like for them, and the limits: volume, freshness, latency, and cost. Components come after.
Turn each requirement into a metric with a definition, a denominator, and a target. "90% accurate" means nothing until you say 90% of what: answerable questions, all questions, or answers shown.
Separate zero-tolerance guardrails, such as a citation to a source the user may not see, from targets that trade off against each other. Also separate offline metrics, measured on an evaluation set, from production metrics taken from traces.
The same metrics later become the evaluation plan and the rollout gate.
The scenario: sources and fixture documents
Worked example
Suppose a fictional invoicing SaaS product adds a support assistant to its signed-in help panel. Customers on the Starter, Pro, and Enterprise plans ask how-to and limit questions. The assistant answers with citations to sources the customer may see, or says it cannot answer and offers a handoff to a human support agent. All names, counts, and documents below are fictional.
| Source | Count | Who may see it | Cited to customers | How it changes |
|---|---|---|---|---|
| Public help articles (HA) | 420 | Every signed-in customer | Yes | About 30 edits and 2 deletions a week |
| Plan articles (PA) | 60 | Customers on the named plan | Only to customers on that plan | About 5 edits a week |
| Internal runbooks (RB) | 150 | Support agents only | Never | Edited by the support team |
| Known-issues page (KI) | 1 page | Every signed-in customer | Yes | Entries opened and resolved daily |
All four live in one content management system (CMS). The CMS records each source's audience and sends an event for every publish, update, deletion, and audience change. Events can arrive late, and occasionally one is lost.
Fixture documents. Assume no other source covers the questions in this scenario's examples and evaluation cases.
| ID | Title | Audience | Current content |
|---|---|---|---|
| HA-12 | Export invoices to CSV | All customers | Revision 4, published yesterday: Invoices > Export > CSV, at most 10,000 rows per export. Revision 3 said 5,000 rows. |
| HA-31 | Plans and limits | All customers | Starter: 1 user. Pro: up to 5 users. Enterprise: unlimited users and SAML single sign-on (SSO). |
| HA-40 | Invite a team member | All customers | Settings > Team > Invite. The invite fails when the plan's user limit is reached. |
| PA-07 | Set up SAML SSO | Enterprise customers | Step-by-step SSO setup |
| RB-05 | Restore a deleted invoice | Support agents | Admin-console steps to restore an invoice a customer deleted |
| HA-55 | Connect the legacy payments plugin | Deleted yesterday | The plugin was retired |
Requirements and budget inputs
Worked example
All requirements and figures are fictional. Retrieval ranking is out of scope: treat retrieval as one stage with its budget.
Requirements
- About 20,000 customer questions a day, each handled by one model request. A conversation has at most 4 turns, and follow-up questions use the conversation so far.
- The customer's account and plan come from the session and the billing service on every request.
- Every factual statement in an answer cites at least one source the customer may see.
- When the sources do not support an answer, the assistant says so and offers a handoff to a human agent. Planning assumption: 20% of questions end this way.
- Within 15 minutes of an update, deletion, or audience change in the CMS, answers stop using the old content.
- An answer cache for repeated first-turn questions is planned, with a 24-hour expiry.
- Latency, measured at the server: p95 time to first streamed token at most 2.0 s; p95 full answer at most 6.0 s.
- Cost: at most $0.02 per answered question. Cost per answered question is all model and retrieval spend for the day divided by the questions answered with citations that day.
Token caps per request. For budgeting, price every request at these caps.
| Part | Tokens |
|---|---|
| Instructions and output rules | 1,200 |
| Conversation history (cap) | 800 |
| Customer question (cap) | 100 |
| Retrieved chunks | 6 chunks of 350 |
| Answer output (cap) | 400 |
| No-answer output | 100 (the full input is still sent) |
Prices. Input $3.00 per million tokens, output $13.00 per million tokens, and $0.0006 per request for query embedding and search.
Latency budget per stage (p95)
| Stage | p95 |
|---|---|
| Session and plan lookup | 50 ms |
| Query embedding | 100 ms |
| Filtered retrieval | 250 ms |
| Context assembly and source labels | 50 ms |
| Model time to first token | 1,200 ms |
| Streaming the rest of a 400-token answer | 4,000 ms |
| Citation resolution and access recheck | 100 ms |
Two paths with access built in
Ingestion copies each source's audience from the content system, the source of truth, onto every chunk. At query time, derive the eligible audiences from the authenticated session and a trusted account service, never from conversation text: a customer who types "I'm on Enterprise" has not changed plan.
Apply eligibility before ranking and generation. A prompt rule such as "never cite internal documents" is not a control, because content that reached the model can be paraphrased without a citation. Content no customer may ever see can stay out of the customer index entirely (OWASP LLM08).
Retrieval is one stage with its own latency budget; ranking belongs to Embeddings & Retrieval.
Build citations from trusted records
The application labels the selected chunks S1, S2, and so on, and maps each label to a trusted source record (article ID, revision, title, URL). The model writes labels, never links.
Labels not in the map are dropped. A statement left without a valid citation is removed, or the turn falls back to no-answer.
Check access when evidence is selected and again when a citation renders: a plan can change or an article can be deleted in between, even in a reopened conversation.
Citation precision is the share of citations that support their statement; citation recall is the share of statements fully supported by their citations (Liu et al. 2023; Gao et al. 2023, ALCE). A real article can still fail support.
Define the no-answer path
The no-answer path has two triggers: no eligible evidence passes retrieval, or the supplied passages do not support an answer and the generator returns the no-answer form instead of guessing.
The customer sees a plain statement that the help center does not cover the question, with no guessed policy, and a handoff to a human agent that carries the conversation so the agent does not start over.
Keep the message generic. "There is an internal procedure for that" tells the customer that a restricted source exists.
Measure the path from both sides, as the evaluation set section below explains.
Updates and deletion reach every copy
Drive reindexing from CMS events (publish, update, delete, audience change), backed by a periodic reconciliation against the index. Events can be late or lost, and some indexing services detect changes automatically but need an explicit strategy for deletions.
An update replaces the article's chunks with the new revision's chunks, a deletion removes them, and an audience change rewrites their audience metadata.
Derived copies count too: answer-cache entries built from the article, and citations in old conversations, which should resolve through current source records. Measure freshness lag from the event until the index and cache reflect it. This topic's Hard question covers races with in-flight answers and multi-tenant isolation.
Budget tokens, cost, and latency
Request tokens are instructions + capped history + question + k × chunk size, plus the output cap, counted with the model's own tokenizer.
Request cost is input tokens × input rate + output tokens × output rate, with rates per million tokens, plus any per-request retrieval charge. A cost per outcome divides all spend by the number of outcomes, so requests that end without that outcome still add to the spend.
Time to first token covers every stage before the first streamed token. Waiting for the whole answer before showing anything moves the first visible token to the full-answer time.
Stage percentiles do not add exactly. Use stage allocations for planning, and measure end-to-end p95 from traces.
Design the query path within budget
Design the path from a customer's question to the rendered answer, then check it against the scenario's budgets.
Design exercise
Design the query path within budget
Use the sources, fixture documents, requirements, and budget inputs in the two scenario sections. Lay out what happens between a customer's question and the rendered answer with its citations, then price and time one request before you reveal the reference design.
Requirements
- Only sources the customer may see reach the model or the screen
- Every displayed citation resolves to a current source record the customer may see
- p95 time to first token at most 2.0 s and p95 full answer at most 6.0 s
- At most $0.02 per answered question
Deliverables
- Components and data flow in order, with the two places access is checked
- How a source label in the model's output becomes a displayed link
- Tokens and cost for an answered and a no-answer request, and the day's cost per answered question
- First-token and full-answer latency, and whether citations can wait for the whole answer
Design the evaluation set
Build cases of several types: answerable from one passage, multi-passage, unanswerable, restricted (answer only in a source the asker may not see), plan-boundary pairs (one question from two plans), stale after an update, and deleted source. Draw them from past tickets; label synthetic ones as synthetic.
Label each case with the expected behavior, the sources it must cite, and the sources it must not cite or use; the forbidden list catches leakage.
Name each metric with its denominator. Report correct and unnecessary no-answers together: an assistant that always declines is perfect on the first. Leakage is a count with target zero, not an average.
Write the gate before reading results. Scoring and uncertainty belong to Evaluation & Observability.
Classify candidate evaluation cases
Each row is a candidate case for the scenario's evaluation set. Classify it with the case types above.
Predict the outcome
Classify candidate evaluation cases
Each row is a candidate evaluation question and who asks it. Using the fixture documents, decide the case type and the behavior the assistant must show before you reveal them.
| Case | Question | Asker | Case type | Required behavior |
|---|---|---|---|---|
| E1 | How do I export my invoices to CSV? | Starter customer | ? | ? |
| E2 | I'm on Starter. How do I add my accountant as a second user? | Starter customer | ? | ? |
| E3 | Can I pay my subscription with cryptocurrency? | Pro customer | ? | ? |
| E4 | How do I restore an invoice I deleted by mistake? | Pro customer | ? | ? |
| E5 | How do I set up SSO? | Pro customer | ? | ? |
| E6 | How do I set up SSO? | Enterprise customer | ? | ? |
| E7 | What is the most rows I can export to CSV at once? | Starter customer | ? | ? |
| E8 | How do I connect the legacy payments plugin? | Pro customer | ? | ? |
Roll out a prompt change
A prompt is versioned configuration. Record its version in every trace and in answer-cache keys.
Run the full offline set on the candidate version and apply the gate written before the run.
Then run a canary: send a small share of conversations to the new version and compare it with the current version over the same period, on restricted exposure, unknown citation labels, handoff rate, cost per answered question, and latency. State the stop conditions in advance.
Roll back by switching the version back. Cached answers from the new version stop being served, because their cache key carries the version.
Completion checklist
- I can state each requirement as a metric with a target and a denominator.
- I can trace a citation from source label to rendered link, with both access checks.
- I can label an evaluation case with its type, required citations, and forbidden sources.
- I can compute the request budget and the day's cost per answered question.
- I can describe a prompt rollout with a pre-stated gate, a canary, and rollback.
Sources
- Gao, Yen, Yu, Chen (2023): Enabling Large Language Models to Generate Text with Citations (ALCE) Defines citation recall and citation precision for answers with citations, and checks support automatically with an NLI model.
- Liu, Zhang, Liang (2023): Evaluating Verifiability in Generative Search Engines Audits cited answers from generative search engines with citation recall and citation precision, and finds that fluent cited answers often contain statements their citations do not support.
- OWASP Top 10 for LLM Applications 2025: LLM08 Vector and Embedding Weaknesses Permission-aware vector stores, fine-grained access control, and classifying knowledge-base data by access level.
- Anthropic docs: Define success criteria and build evaluations Success criteria should be specific and measurable, including latency percentiles and per-call price, with task-specific evaluations that include edge cases.
- Microsoft Learn: Changed and deleted blobs (Azure AI Search) An example indexing service that detects new and changed content automatically but needs an explicit soft-delete strategy to detect deletions.
- Google SRE Workbook: Canarying Releases Compares a canary with a control on metrics and acceptable behavior chosen beforehand, and rolls back when the canary diverges.
The company, articles, runbooks, requirements, prices, latencies, evaluation cases, and rubric are original synthetic teaching material about a fictional support assistant; the prices and timings are not quotes from any provider. Study times and readiness thresholds are editorial estimates. Search and model services differ, so check the selected service's current documentation. Product details are as of November 2026.
Related on CodeSnatch
Lessons, problems, and articles that build the skills this question uses.
System Design
Compares event-driven invalidation, TTLs, and versioned keys for an answer cache that must follow edits and deletions.
Practice problem
Score answer and abstain cases with separate denominators, the counting behind correct and unnecessary no-answers.
AI Engineering
Works cost per question and first-token latency from input length, the same budget arithmetic for another product.
AI Engineering
Goes further on versioned serving configuration, canary decisions, and rollback for a multi-tenant assistant.
System Design
A round structure that settles requirements and estimates before components, as this design question expects.
Practice the interview question
Answer it in your own words before you look at the reference answer.
