Most RAG demos stop at "it answered". You ask three questions, the answers look right, and the demo goes well. Then someone changes the chunk size, swaps the model or tidies the prompt, and retrieval gets slightly worse. No exception is thrown and no test fails. The regression ships, and the first person to notice is a user.
I built agentic-rag-evals, an open-source tool-calling RAG agent, around that problem. The agent is small on purpose. The part worth copying is the harness around it, which treats answer quality like any other thing a change can break.
Start with a golden set, and keep it small
A golden set is a list of questions with what a correct run has to contain. Mine is 11 cases in a JSONL file: 9 factual questions, 1 arithmetic question and 1 question the knowledge base can't answer. It's small enough to read in one sitting, which matters, because you'll maintain this file by hand. Treat it as a template for a larger set from your own domain, not as a benchmark.
json{"id": "refund-window", "question": "How long do customers have to request a full refund?", "expected_docs": ["refund-policy"], "expected_substrings": ["30 days"], "expected_tools": ["search_docs"]}
Each case states three separate expectations: which document should be found, what the answer must contain, and which tools should be called. Keeping them separate is the point of the whole design, as you'll see below.
The unanswerable case is the one people skip, and I think it's the most useful. It asks about something that isn't in the documents and expects the agent to say it doesn't know. Without it, a model that confidently makes things up would pass every test you have.
One pass rate isn't enough: score each layer
A single accuracy number tells you something broke, not where. So the harness records several metrics per case:
pythonhit = (not expected) or any(d in docs for d in expected) match = all( s.lower() in res.answer.lower() for s in case["expected_substrings"] ) grounded = all(c in docs for c in res.citations) tools_ok = all(t in res.tools_used for t in case["expected_tools"]) passed = hit and match and grounded and tools_ok
Retrieval hit asks whether the right document came back. Mean reciprocal rank, recorded alongside it, asks how high it ranked. Answer match asks whether the facts made it into the final text. Grounded asks whether every citation points at a document the tools really returned. Tool accuracy asks whether the agent took the expected path.
Substring matching looks crude next to LLM-judged scoring, and for subjective answers it is. For factual answers it has real advantages: it's fast, it's free, and it gives the same result every time. A flaky quality gate gets ignored within a week, so I'd take a blunt check that's stable over a clever one that isn't.
Keep a known failure in the set
The current baseline is 10 of 11 passing, and the failure is deliberate. The free-limit case retrieves the correct document, but the offline mock picks the wrong sentence from it. I left it in because it shows the harness doing its job: retrieval scores 1.00 while that one case fails on the answer. If I only had a single score, that would look like a vague drop. Here it's clearly an answer-selection problem and not a retrieval problem, so I know which half of the system to look at.
A harness that has never failed hasn't shown you it can fail. Keep at least one case that proves the alarm works.
Make it cheap enough to run on every change
If evals cost money per run, people stop running them. So the project runs fully offline by default, with a deterministic MockLLM that follows the same interface as a real client. Pass --live and the same harness runs against any OpenAI-compatible endpoint. Everyday runs cost nothing, and you spend on real-model runs when you choose to.
A mock doesn't tell you how good a real model is. It's a policy stub, and real-model results will differ. What it does catch is everything around the model: chunking, ranking, the agent loop, citation filtering and tool validation. Those are the changes that happen most often.
The gate itself is an exit code
The last line of the harness is what turns a report into a gate. Below the threshold, the process exits non-zero:
pythonreturn 0 if report["summary"]["pass_rate"] >= args.threshold else 1
Any CI system can act on that, so the pipeline step is one line next to your unit tests:
yaml- run: pytest -q - run: python -m evals.run_evals --threshold 0.9
Do the arithmetic on your threshold. With 11 cases, a 0.9 gate tolerates exactly one failure: 10 of 11 is 0.91 and 9 of 11 is 0.82. Since one failure is already in the baseline, any new failure blocks the merge, which is what I want at this size. As the set grows, the same 0.9 starts allowing more failures, so recheck the number when you add cases.
What to do on Monday
You don't need a platform for this. Write ten questions you already know the answers to, including one the system should refuse. Record the expected document and a phrase the answer must contain. Score retrieval and answer separately, then exit non-zero below a threshold. That's an afternoon of work, and from then on a bad prompt edit fails a check instead of reaching a customer.



