Chapter 9 · concept 6 of 6 · show all
2Tokens, cost and your first RAG
4Chunking
- 4.1Why we chunk, and the main chunking strategies
- 4.2Structure aware chunking and tables
- 4.3Chunk size, overlap and token based sizing
- 4.4Contextual chunking and late chunking
- 4.5Parent child and multi representation indexing
- 4.6Chunk metadata, provenance and the chunking debugging playbook
- Chapter overview
7Finding the right chunks
8When retrieval fails
Conversational RAG, answer UX and RAG APIs
Follow-up questions, showing sources, collecting feedback and returning structured answers. We searched 7 follow-ups three ways: as typed, glued to the previous question, and rewritten.
A real question
A user asks “What about 1011 in May?”. What does the search engine see?
Only those five words, unless you rewrite them. A conversational RAG system turns follow-ups into stand-alone questions, shows its sources, accepts feedback and returns answers in a shape other programs can use.

The problem
Why this matters

Add the previous question to the follow-up, and search has the context it needs.

On 7 follow-ups we wrote, gluing found the answer in the top 3 for 5, typed alone for 6, and a stand-alone rewrite for all 7. The old question's words pulled search back to the old topic.
Why not the simpler way
Most RAG demos answer one question at a time. Real users have conversations: they ask, read, and follow up with "and for the washing machine?" or "what about last year?". Without handling that, the second question fails even though the system answered the first one well. The answer also has to reach the user, and other systems, in a usable form.
The idea
The idea in plain words
Conversational RAG keeps enough of the conversation to understand follow-ups, and searches with a rewritten, stand-alone question. Answer UX shows the answer with its sources, makes abstentions useful, and collects feedback. A RAG API returns a structured response other programs can rely on.
A good help desk agent repeats your question back in full before looking it up: "So you want to know how long the decision takes once your claim is complete?"
How it works
Step by step
1Rewrite follow-ups
Turn “What about 1011 in May?” into “Is flood damage covered in postcode 1011 in May 2026?” using the last few turns.
2Show sources, ask for feedback
Show citations as links to the exact document and version. A thumbs up or down with an optional reason feeds your evaluation.
3Return structure
Answer text, citations with ids, an abstained flag and a trace id. The interface and the logs both need them.
In detail
Rewrite. A small model gets the last few turns and the new message and returns one stand-alone question (RAG-26). Keep codes, numbers and dates exactly. Skip the rewrite when the message is already stand-alone.
Memory. Keep recent turns verbatim, summarize older ones (RAG-35). Do not carry old retrieved chunks forward by default; search again with the rewritten question.
UX. Citations as clickable sources with document title and version; a clear abstention message with a next step; streaming text so users see progress; feedback buttons tied to the trace id.
API shape. { answer, citations: [{ id, doc, version, url }], abstained, trace_id, model, latency_ms }. Version the API so clients survive changes.
The code
Try it in Python
from dataclasses import dataclass, field
@dataclass
class Citation:
id: int
doc: str
version: str
url: str
@dataclass
class RagAnswer:
answer: str
citations: list[Citation] = field(default_factory=list)
abstained: bool = False
trace_id: str = ""
rewritten_question: str = ""
def handle(message, history, rewrite, retrieve, generate, trace_id):
question = rewrite(history[-4:], message) if history else message
sources = retrieve(question)
text, cited = generate(question, sources)
return RagAnswer(text, cited, text.startswith("I don't know"), trace_id, question)
See it
What we measured
Measured · answer chunk in the top 3 for follow-up questions
Polder corpus, 34 recursive 512 token chunks, hybrid search. 7 follow-ups written by us, each after a golden question. Rewritten = the matching golden question, written by hand as the ideal rewrite.
Measured 2026-11-04 with corpus/scripts/measure-parts-6-7.mts. Our follow-ups often repeat key words, so typing alone did well; model-written rewrites were not measured (not measured yet).
Try it on a real example
Follow-up after “Within how many days must I report home contents damage?”
Query
Answer chunk at rank 11. “It” and “you” mean nothing to search.
Choosing
Use it when, avoid it when
- A stand-alone rewrite for follow-ups, logged
- Structured answers with citations and an abstained flag
- Gluing previous turns onto the query
- Returning only a text string from a RAG API
What it costs · One small model call per follow-up for the rewrite. Structure and feedback cost almost nothing.
In production
Log the original message, the rewrite, the retrieved ids and the answer under one trace id (RAG-48). Follow-up failures are usually rewrite failures, and the log shows it in seconds. Add follow-up conversations to the golden set as short scripts: two or three turns with the expected answer for the last one.
Watch out
Common mistakes
- Chat history solves follow-ups. The search still needs one clear question.
- More history in the query helps. Gluing found fewer answers than typing alone here.
- Users read the sources. Many do not; make the most important source easy to open.
Check yourself
Remember this
Remember these
- Rewrite follow-ups into stand-alone questions before search.
- Gluing the previous turn on is not a rewrite: 5 of 7 versus 7 of 7 here.
- Show sources as links and collect feedback with a reason.
- Return structured answers: text, citations, abstained flag, trace id.
Say it in an interview
- 01I rewrite follow-ups into stand-alone questions and log both.
- 02On my 7 follow-ups, gluing the previous question found 5, a rewrite found 7.
- 03Answers return as structured data: text, citations, an abstained flag and a trace id.
- 04Feedback is tied to the trace id so bad answers can be replayed.
- 05Multi-turn conversations are part of my golden set.
Quick quiz