Agentic RAG capstone: compare versions and document results
Compare all three versions on the fixture suite with zero cross-scope disclosures and document evidence, limitations, cost and rollback.
By Invicly Tech, , in Generative AI, Agentic AI and RAG. About 13 minutes to read.
In short
Verification runs the same 20 fixture cases against the model-only baseline, fixed RAG and the bounded agent, then reports what each version got right, what it cost and where it failed. It must show missing-source and denied-document behaviour, prove zero cross-scope disclosures, and end with a written record of evidence, limitations, cost and a rollback plan.
Think of it like this: It is a road test for three cars on the same course with the same stopwatch, where any car that drifts into the wrong lane fails outright.
Explained simply
Verification answers one question: is the extra complexity worth it? You run the same 20 test cases through all three versions of the assistant and compare the scores side by side. If the agent is slower and costs more but is not more correct, the simpler version wins.
Some checks are pass or fail on their own. The biggest is that no finance document may ever reach a general caller, in any version, in any case. One leak fails the whole run, however good the other numbers look.
Two behaviours need to be shown clearly. When no document covers a question, the assistant should say it cannot answer instead of guessing. When the only answer sits in a document the caller cannot see, it should give the same kind of refusal, without hinting that the hidden document exists.
Then write it up. A short report lists each score, the cost per request of each version, where each one failed and why. Add a cleaned-up trace of one request, honest limitations and a checklist for releasing and undoing a release. Mark numbers from the fake model as illustrative.
Press Play on a diagram to walk through it one step at a time.
- 1Load fixtures v1
20 cases; corpus, index, prompt and budgets pinned
- 2Run each mode
Same cases and callers, fixture mode
- 3Deterministic checks
Status, citations, forbidden sources, tool allowlist
- 4Compute metrics
Recall, support, completion, tools, latency, cost
- 5Gate and report
Zero disclosures, targets met, diff against last run
- Recall@5: not applicable
- Correct status: 6 of 20
- Cross-scope disclosures: 0
- No tool calls, fastest
- Recall@5: 0.88
- Correct status: 15 of 20
- Cross-scope disclosures: 0
- Misses two-document and ambiguous cases
- Recall@5: 0.94
- Correct status: 18 of 20
- Cross-scope disclosures: 0
- Median 2 tool calls, slowest
- Retrieval
- Expected source not in top 5
- Stale version retrieved
- Generation
- Answer not supported by cited text
- Wrong status chosen
- Citation
- Cited ID not in permitted evidence
- Tools and budget
- Tool timeout
- Repeated or useless calls
- Budget exhausted
- Access
- Forbidden source cited: release blocker
In depth
Running the suite fairly
Pin everything except the mode: fixture set version, corpus version, index build ID, prompt version, model ID (the fake model in fixture mode) and budgets. Save these in a run manifest next to the results. Run every case in every mode with that case's caller token. Expected outcomes may differ by mode; model-only, for example, should abstain or be scored unsupported on policy questions.
For the two tool-timeout cases, the mock ticket tool sleeps past its 2 second limit; the expected agent status is escalated with tool_timeout. A typical command pair is pytest -q tests/eval followed by your report script. Expected evidence: 60 results (20 cases times 3 modes), a manifest and a report.
Run the suite twice. In fixture mode the statuses and citations should be identical; any difference is a harness bug to fix before you trust any number.
- Pin fixture, corpus, index, prompt, model and budgets
- Only the mode changes between runs
- 60 results plus a manifest per run
- Two identical fixture runs prove determinism
Metrics and how each is computed
Recall@5: for answerable cases, the share of expected documents found in the top 5 permitted results; not applicable to model-only. Citation support: the share of citations whose text backs the claim, checked first deterministically (figures and dates present in the cited text), then optionally by model grading that you calibrate against 20 to 30 answers you labelled yourself. Task completion: the status matches the expected status for that mode, and answered cases are supported.
Tool count: median and maximum calls per request, plus unnecessary calls such as repeats or calls that added no new evidence. Latency: p50 and p95 per mode from server timings. Cost: token counts times a dated price table for the model you would use, labelled as an estimate in fixture mode. Disclosures: forbidden documents cited or forbidden text shown; this must be zero.
Showing missing-source and denied-document behaviour
Pick one case of each and show the request, response and redacted trace side by side. Missing source: a general caller asks about a benefit no document covers. The expected response is abstained, reason no_permitted_evidence, no citations. Denied document: a general caller asks for the vendor payment approval limit, which only FIN-002 covers. Retrieval runs with scopes set to general and returns only unrelated general sections, so the model abstains and the citation check has nothing to pass. The response is the same shape and reason as the missing-source case.
Then send the same question with a finance caller's token. It should be answered with a citation to FIN-002. That contrast proves the filter, not the model's discretion, is doing the work.
- General caller to API: Approval limit for vendor payments?1Approval limit for vendor payments?
- API to Retrieval: Search with scopes = general2Search with scopes = general
- Retrieval to API: Only unrelated general sections3Only unrelated general sections
- API to General caller: abstained: no_permitted_evidence4abstained: no_permitted_evidence
- Finance caller to API: Same question5Same question
- API to Retrieval: Search with scopes = general, finance6Search with scopes = general, finance
- Retrieval to API: FIN-002#1@v1 ranked first7FIN-002#1@v1 ranked first
- API to Finance caller: answered, cites FIN-002#1@v18answered, cites FIN-002#1@v1
Results report, redacted trace and limitations
The report holds the run manifest, a metrics table per mode, status counts per category, every failing case with the stage that failed, the cost estimate and a recommendation. The redacted trace keeps span names, timings, section IDs, token counts and statuses. It replaces question and answer text with a hash and length, user IDs with pseudonyms and passages with section IDs.
State limitations plainly. Twenty cases cannot separate small differences: one case moves a rate by 5 percentage points. The corpus is synthetic and small. The fake model hides real variation in wording and refusals. Laptop latency is not production latency. Optional live-model results go in a separate, labelled section with the model ID and date.
- Keep: IDs, timings, counts, statuses
- Replace: text with hash and length
- Replace: user IDs with pseudonyms
- One case equals 5 points in a 20-case suite
Release and rollback checklist
Release gates: zero disclosures, every target met, no category worse than the last accepted run, and the manifest stored with the results. Roll out with the mode as a configuration flag. A cautious plan keeps fixed RAG as the default and turns on the agent for a pilot group, with fixed RAG as the fallback when the agent exhausts its budget.
Write rollback triggers as numbers: any reported disclosure, p95 latency above target for 15 minutes, an abstention rate that doubles against the baseline, or an error rate above an agreed threshold. Rollback steps: switch the mode flag to fixed_rag, or point back to the previous index build, which you kept beside the new one, and restore the previous prompt version. Then rerun the suite against the rolled-back configuration and record the result.
- Gate: zero disclosures, targets met, no category regression
- Mode is a flag; keep the previous index build
- Triggers are numbers, not opinions
- Rerun the suite after every rollback
Learn it in 4 short steps
About 1h 30m each. Track them with a timer in your plan.
- 1Run the 20-case suite on all three versions~1h 30m
- 2Show missing-source and denied-document behaviour~1h 30m
- 3Report recall, support, tools, latency and cost~1h 30m
- 4Publish a redacted trace and rollback checklist~1h 30m
Key points
- Same cases, same callers and the same pinned versions for all three modes. Only the mode changes.
- Deterministic checks run first. Model grading is optional and calibrated against a human-labelled sample.
- A single cross-scope disclosure fails the release, whatever the other scores are.
- Report results per category, not only averages, so failures in denied or stale cases stay visible.
- Label illustrative and live-model figures, and publish only redacted traces.
Key terms
Tap a card to flip it. 0/6 known
Examples
import pytest
from eval.runner import load_cases, run_case
CASES = load_cases("fixtures/cases.v1.jsonl")
@pytest.mark.parametrize("mode", ["model_only", "fixed_rag", "agent"])
@pytest.mark.parametrize("case", CASES, ids=lambda c: c.id)
def test_no_cross_scope_disclosure(case, mode):
result = run_case(case, mode=mode)
cited_docs = {cid.split("#")[0] for cid in result.citations}
assert not cited_docs & set(case.forbidden_docs), f"{case.id} {mode} leaked"
text = result.answer or ""
assert not any(s in text for s in case.forbidden_snippets)The disclosure gate as a pytest test over every case and mode
A redacted trace for one agent request
This trace shows the path the request took and what it cost, without the question, answer or passage text. The caller is a pseudonym, the question is a hash plus length, and evidence appears only as section IDs. All numbers are illustrative fixture-mode values.
{
"request_id": "req-7f3a", "mode": "agent",
"caller": "user-91c2", "scopes": ["general"],
"question": {"sha256_prefix": "5e1b9c0a", "chars": 52},
"spans": [
{"name": "route", "ms": 4, "decision": "retrieve"},
{"name": "search_docs", "ms": 31, "hits": ["POL-003#1@v2", "POL-003#2@v2"]},
{"name": "model.generate", "ms": 220, "in_tokens": 1840, "out_tokens": 96},
{"name": "validate_citations", "ms": 1, "result": "ok"}
],
"status": "answered", "citations": ["POL-003#1@v2"],
"tool_calls": 1, "total_ms": 262
}Reading the comparison table
In this illustrative run the agent completes 18 of 20 cases against 15 for fixed RAG, at more than double the p95 latency, which is still well inside the 8 second target. Both retrieval modes have zero disclosures, so the gate passes. The agent's two failures are an ambiguous question it answered instead of asking for clarification, and a timeout it reported as abstained instead of escalated. Fix those, rerun, and only then recommend the agent for a pilot.
Run 2026-12-02 | fixtures v1 | corpus v1 | index b7 | prompt p3 | fake model
ILLUSTRATIVE FIGURES, NOT LIVE-MODEL RESULTS
mode status_ok recall@5 support tools_med p95_ms disclosures
model_only 6/20 n/a 0.00 0 15 0
fixed_rag 15/20 0.88 0.96 1 410 0
agent 18/20 0.94 0.97 2 980 0
Agent failures:
C09 ambiguous -> answered (expected clarify) stage: generation
C17 tool timeout -> abstained (expected escalated) stage: toolsQuick reference
- Run every case in every mode: 20 cases x 3 modes = 60 results, plus a run manifest.
- Pin fixture, corpus, index, prompt, model and budget versions. Only the mode may change.
- Recall@5 = expected documents in top 5 / expected documents, on answerable cases only.
- Zero cross-scope disclosures is a release blocker, not a metric to average.
- Denied and missing evidence should return the same status and reason.
- With 20 cases, one case moves a rate by 5 points. Do not over-read small gaps.
- Redact traces: keep IDs, timings and counts; hash or drop question, answer and passage text.
- Rollback: switch mode to fixed_rag or point back to the previous index build, then rerun the suite.
Common mistakes
- Reporting one average score that hides a failing category such as denied access.
- Changing the prompt or corpus between the three runs, so differences come from versions, not modes.
- Publishing raw traces that contain question text, user IDs or document passages.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Write the run manifest for one evaluation run.
- Exercise 2medium
Write a function that computes mean recall@5 over answerable cases from a list of results.
- Exercise 3hard
Write the release and rollback checklist for moving the default mode from fixed_rag to agent, with measurable triggers.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is 20 cases enough?
- It is enough to prove each category is handled and to catch leaks, not enough to detect small quality differences. Grow the set as real failures appear and keep old cases as regression tests.
- Should I use a model to grade answers?
- Start with deterministic checks. If you add model grading, compare it with your own labels on a sample and trust it only where the two agree.
- How do I report cost without a paid model?
- Report token counts from the fake model's simulated usage and multiply by a dated price table for the model you would use, labelled as an estimate. Any live run is optional and reported separately.
- What if the simpler version wins?
- Ship the simpler version. The comparison exists to justify complexity with evidence, and fixed RAG with good retrieval is often the right answer.