Where I put guardrails, what I test, and why the evaluation harness needs testing too.
- 3Guardrail layers in Hybrid RAG
- 30/30Evaluations passed
- 5Evaluation suites
- 223Tests in ReviewLens, no real model calls
01 · Where guardrails go
At the points where bad things get in.
A guardrail inside the prompt is only a request. Across the builds I put them outside the model, at different points of the flow.
- InputOut-of-domain, empty, prompt-injection and unsafe requests are stopped before retrieval.
- RetrievalA check on whether what came back actually supports the question.
- EvidenceCovers the cases where semantic retrieval alone is not enough to support an answer.
- OutputIn the CrewAI build, a separate output guardrail checks the result.
- FreshnessWords such as latest or upcoming are caught so an old date is never presented as current.
02 · What I test
The behaviour, not just the happy path.
The Hybrid RAG evaluation has five suites, each with its own script, and includes deliberate negatives: an unsupported crop, an unsupported tractor question, a missing scheme field and an out-of-domain cricket question.
- Input guardrails10 / 10
- Retrieval guardrails8 / 8
- Evidence support4 / 4
- Hybrid retrieval4 / 4
- Final answers4 / 4
03 · Keeping evaluation honest
Judge with different evidence than you generated with.
In the CrewAI build, the evidence used to generate an answer is kept separate from the evidence used to judge it. Decision validation is deterministic and trace-based, checking the routing trace, the allowed capabilities, tool-trace integrity and action claims, with no extra model or search calls.
In ReviewLens a mocked model lets the whole suite run offline, including 22 tests of invalid-output retries, so behaviour is checked without paying for a call.
04 · The part people skip
Test the evaluator too.
In AI Agent Olympics the evaluator was regression-tested and corrected after it wrongly treated quoted misinformation as adopted misinformation. A wrong judge makes every result wrong in the same direction, and nobody notices.
Evaluation engineering must itself be tested.
05 · Use it yourself
A starter test set you can copy.
Thirty cases is enough to start. Write them before changing anything, and rerun them after every change.
- Normal questions (10)Typical requests that should be answered. They show the system works when things go well.
- Out of scope (5)Questions the source cannot answer. The right behaviour is to say so, not to guess.
- Hostile input (5)Instructions to ignore the rules, requests for the system prompt, abusive and unsafe wording. The right behaviour is a calm refusal.
- Odd input (5)Empty, very long, garbled and mixed-language questions.
- Traps (5)Questions with a false premise, or that tempt the system to invent a number or a name.
06 · Pitfalls
Mistakes that make a good score meaningless.
- Guardrails only in the promptA prompt is a request, not a control. Put checks in code, before and after the model.
- Only happy pathsA suite of easy questions passes by construction. Include cases that should fail safely.
- Marking your own homeworkIf the same model and evidence generate and judge an answer, errors agree with themselves. Separate them.
- No baselineA score of 90% means little until you know what 90% was before. Record results over time.
- A bug that is not a testEvery failure found in use should become a case in the set, so it cannot quietly return.
What I took away
- Put guardrails at the points where bad input, weak evidence and stale facts enter.
- Include deliberate negatives in the suite; a system that only passes good questions has not been tested.
- The evaluation harness is part of the system and needs its own tests.