AI Engineering
/
RAG & Data Pipelines
/

Design a cited support assistant with measurable quality

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.

Medium
System Design

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.

SourceCountWho may see itCited to customersHow it changes
Public help articles (HA)420Every signed-in customerYesAbout 30 edits and 2 deletions a week
Plan articles (PA)60Customers on the named planOnly to customers on that planAbout 5 edits a week
Internal runbooks (RB)150Support agents onlyNeverEdited by the support team
Known-issues page (KI)1 pageEvery signed-in customerYesEntries 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.

IDTitleAudienceCurrent content
HA-12Export invoices to CSVAll customersRevision 4, published yesterday: Invoices > Export > CSV, at most 10,000 rows per export. Revision 3 said 5,000 rows.
HA-31Plans and limitsAll customersStarter: 1 user. Pro: up to 5 users. Enterprise: unlimited users and SAML single sign-on (SSO).
HA-40Invite a team memberAll customersSettings > Team > Invite. The invite fails when the plan's user limit is reached.
PA-07Set up SAML SSOEnterprise customersStep-by-step SSO setup
RB-05Restore a deleted invoiceSupport agentsAdmin-console steps to restore an invoice a customer deleted
HA-55Connect the legacy payments pluginDeleted yesterdayThe 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.

PartTokens
Instructions and output rules1,200
Conversation history (cap)800
Customer question (cap)100
Retrieved chunks6 chunks of 350
Answer output (cap)400
No-answer output100 (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)

Stagep95
Session and plan lookup50 ms
Query embedding100 ms
Filtered retrieval250 ms
Context assembly and source labels50 ms
Model time to first token1,200 ms
Streaming the rest of a 400-token answer4,000 ms
Citation resolution and access recheck100 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.

CaseQuestionAskerCase typeRequired behavior
E1How do I export my invoices to CSV?Starter customer??
E2I'm on Starter. How do I add my accountant as a second user?Starter customer??
E3Can I pay my subscription with cryptocurrency?Pro customer??
E4How do I restore an invoice I deleted by mistake?Pro customer??
E5How do I set up SSO?Pro customer??
E6How do I set up SSO?Enterprise customer??
E7What is the most rows I can export to CSV at once?Starter customer??
E8How 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

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.

Practice the interview question

Answer it in your own words before you look at the reference answer.