Search Tutorials
--Ads--User Feedback Loops and Continuous Improvement
Collect user feedback and turn it into test cases and fixes.
A RAG system is never finished. Documents change, users ask questions nobody anticipated, and every failure is information about what to improve. A feedback loop turns real usage into a steady stream of fixes and new test cases, so the system gets better each week instead of slowly drifting.
Collect feedback signals
| Explicit signals | Implicit signals |
|---|---|
| Thumbs up / thumbs down on each answer | User immediately rephrases the same question |
| Optional comment ("wrong number", "outdated") | User escalates to human support after an answer |
| "Was this source helpful?" on citations | User copies the answer (a positive sign) |
| Reports from support agents and content owners | Answer says "not found" (possible content gap) |
Explicit feedback is sparse (most users never click), so combine it with implicit signals. Link all of it to the trace ID from Observability, so each piece of feedback comes with the full context of what happened.
A feedback endpoint
from datetime import datetime, timezone
from typing import Literal
from pydantic import BaseModel, Field
class Feedback(BaseModel):
trace_id: str
rating: Literal["up", "down"]
comment: str = Field(default="", max_length=1000)
@app.post("/feedback")
async def feedback(fb: Feedback):
record = {**fb.model_dump(), "received": datetime.now(timezone.utc).isoformat()}
with open("feedback.jsonl", "a", encoding="utf-8") as f: # use a database in production
f.write(json.dumps(record) + "\n")
return {"status": "thanks"}
Triage: why did it fail?
Every negative case falls into one of a few categories, and each category has a different owner and fix:
| Category | Symptom in the trace | Typical fix |
|---|---|---|
| Content gap | No document contains the answer | Content owners write or update documentation |
| Stale content | Retrieved document is outdated | Archive old versions, fix ingestion freshness |
| Retrieval miss | The answer exists but was not retrieved | Chunking, hybrid search, query rewriting, metadata |
| Generation error | Right chunks retrieved, wrong or unsupported answer | Prompt changes, citations, effort |
| Out of scope | Question the assistant should not answer | Routing, clearer "can't help" message |
An LLM can pre-classify negative traces to speed up review. A person should confirm the category before acting on it.
from pydantic import BaseModel
import anthropic
client = anthropic.Anthropic()
class Triage(BaseModel):
category: Literal["content_gap", "stale_content", "retrieval_miss", "generation_error", "out_of_scope"]
explanation: str
def triage(trace: dict, comment: str) -> Triage:
chunks = "\n\n".join(trace["retrieved_texts"])
return client.messages.parse(
model="claude-opus-5-5", max_tokens=1000, output_config={"effort": "medium"},
messages=[{"role": "user", "content":
f"A user rated this RAG answer as bad.\nQuestion: {trace['question']}\n"
f"Retrieved chunks:\n{chunks}\n\nAnswer: {trace['answer']}\nUser comment: {comment}\n\n"
"Classify the most likely cause of the failure."}],
output_format=Triage,
).parsed_output
Turn failures into test cases
Every confirmed failure becomes a case in your golden test set (Building a Golden Test Set), with the correct reference answer and evidence. The fix is then verified by the regression tests, and the failure can never silently return.
Close the loop with content owners
Many failures are not engineering problems. Send a regular report to document owners: questions with no answer in the documents, documents that are retrieved often but rated badly, and detected contradictions between sources. Improving the source content often helps more than any retrieval technique.
A weekly routine
- Review all thumbs-down answers and a random sample of other answers.
- Triage and assign each failure: content, ingestion, retrieval or prompt.
- Add confirmed failures to the golden set.
- Ship fixes behind the regression tests (A/B and Regression Testing).
- Track trends: thumbs-down rate, "not found" rate and the top unanswered topics.
Key takeaways
- Collect explicit and implicit feedback, linked to request traces.
- Triage failures into content gaps, stale content, retrieval misses, generation errors and out-of-scope questions.
- Turn every confirmed failure into a regression test case.
- Report content problems to document owners; better content is often the best fix.