# Checking LLM Answers Against Tool Results Without Blowing Up Context > Guilherme Ribeiro compares five grounding checks across 32 synthetic test cases, measuring accuracy, latency, and token use as tool-result evidence grows. - URL: https://techblog.loka.com/checking-llm-answers-against-tool-results-without-blowing-up-context/ - Type: Blog article - Authors: Guilherme Ribeiro (Advanced ML Engineer) - Published: 2026-10-27 - Reading time: 12 min - Tags: AI Agents, Amazon Bedrock, Strands Agents, LLM Evaluation, Grounding, Benchmarks - Topics: agents, benchmarks --- _How do you keep a cheap, fast grounding check reliable when the evidence it has to read keeps growing?_ ## The setup Say you’re building an assistant that answers questions about a patient’s medications. It has tools like `get_medications`, and it calls them as needed to answer things like _“what is this patient currently taking?”._ Because this kind of assistant is one hallucinated detail away from misleading a clinician, suggesting conflicting medications, or affecting a patient’s treatment, every response needs a **grounding guardrail**: a check that verifies the assistant’s answer is actually backed by the tool results it was given. To run that check on _every single turn_ without tanking latency or cost, the natural choice is a small, fast model like Anthropic Claude Haiku. Not the frontier model generating the answer itself. That works fine at first. The trouble starts as sessions get longer. More tool calls, more paginated results, more history and the evidence grows well past what a small model can reliably reason over in one pass. ## The problem: splitting evidence breaks multi-fact answers The first instinct is to **split the evidence into chunks and check each one in parallel**. Each chunk gets checked independently, and the verdicts get combined at the end. This has a problem: if a response is grounded by two _different_ facts that happen to live in two _different_ chunks, each chunk only ever sees half the picture. For example: _“\[…] this patient is currently taking medication A for blood pressure and medication B for cholesterol.”_ Medication A’s record lives in one page of tool results; medication B’s lives in another. If the guardrail checks each chunk against the _whole_ response, chunk 1 only ever confirms half of it, chunk 2 only confirms the other half. A naive logic like “every chunk must fully confirm the response” fails the whole thing, even though the two chunks _together_ fully support it. Why independent chunk checks fail 1. **User question**What is this patient taking? 2. **Call get\_medications**Tool results arrive in separate pages. 3. **Page 1**Medication A **Page 2**Medication B 4. **Assistant response**The patient is taking medication A and medication B. 5. Each check gets the whole answer but only its own page **Chunk 1 check**Confirms medication A only. **Chunk 2 check**Confirms medication B only. 6. **Naive reduce: reject**Neither chunk confirms the complete answer on its own. The answer needs both pages. Each isolated check sees only one medication, so requiring every chunk to confirm the whole answer rejects a supported response. We built and tested five approaches to this problem, using Strands agents on Amazon Bedrock with Claude Haiku 4.5 as the judge model, and ran each one against 32 synthetic test cases. ## The approaches The code snippets below show the structure of each approach; parallel execution and implementation details are omitted. ### A. Per-claim map, code reduce First, one LLM call breaks the response into atomic claims. Each chunk then gets the full claim list but only its own slice of evidence. Instead of returning one verdict for the whole response, the judge model returns a verdict per claim: supported, contradicted, or `not_addressed`. A plain code reduce step then combines the per-claim verdicts across chunks. No extra LLM call. A · Per-claim map, code reduce 1. **Assistant response**The answer to verify. 2. **Extract atomic claims**One model call creates the shared claim list. 3. Parallel checks · full claim list + local evidence **Judge chunk 1**Supported, contradicted, or not\_addressed per claim. **Judge chunk 2**Supported, contradicted, or not\_addressed per claim. 4. **Combine labels in code**For each claim: at least one support, no contradiction. 5. **Final verdict**Grounded only if every claim passes. Every judge receives the same claims and one evidence slice. Code combines the per-claim labels across chunks; there is no final model call. ```py def verify_response(response, evidence_chunks): claims = extract_claims(response) # one LLM call: list of atomic claims votes = {claim: [] for claim in claims} for chunk in evidence_chunks: # run in parallel chunk_verdicts = judge_model.run( PER_CLAIM_PROMPT, claims=claims, evidence=chunk ) # -> {claim: "supported" | "contradicted" | "not_addressed"} for claim, verdict in chunk_verdicts.items(): votes[claim].append(verdict) # a claim is grounded if ANY chunk supports it and NONE contradict it grounded = { claim: "contradicted" not in v and "supported" in v for claim, v in votes.items() } return all(grounded.values()) ``` A claim is grounded if **any chunk supports it and none contradict it**. So evidence for medication A and evidence for medication B can live in different chunks and still both count. **Pros** Tied with B as the fastest of the five (5.9s avg). All judge calls run in parallel, and the reduce step is plain code with no extra LLM call. **Cons** Its misses come in two shapes. The first is a claim that depends on finding or assembling evidence within a very large record set, such as a single fact among 1,500 encounter records. Each chunk only votes on the slice it can see, so when no single chunk holds enough of the picture, the OR-reduce comes up empty even though the response is correct. The second is a later record that cancels or replaces an earlier one by ID only. That chunk looks unrelated on its own, so it votes `not_addressed`, and the OR-reduce keeps the earlier “supported”. ### B. Extractive map, single reduce Each chunk doesn’t render a verdict at all. It extracts relevant quotes and reasoning. All extractions get concatenated, and **one final call** makes the actual judgment call over the combined evidence. B · Extractive map, single reduce 1. **Assistant response**Shared with every extraction call. 2. Parallel extraction · one evidence slice per call **Extract from chunk 1**Relevant quotes and reasoning; no verdict. **Extract from chunk 2**Relevant quotes and reasoning; no verdict. 3. **Concatenate extractions**Plain code gathers the evidence into one context. 4. **Single final judge**Reads the answer and all extracted evidence. 5. **Final verdict**One grounding decision. Extraction happens in parallel, without a verdict. One final judge sees the evidence collected from all chunks together. ```py def verify_response(response, evidence_chunks): extractions = [ judge_model.run(EXTRACT_PROMPT, response=response, evidence=chunk) for chunk in evidence_chunks # run in parallel, no verdict yet ] combined_evidence = "\n".join(extractions) verdict = judge_model.run( FINAL_JUDGMENT_PROMPT, response=response, evidence=combined_evidence ) return verdict.is_grounded ``` **Pros** Its single final reduce call sees every chunk’s extracted evidence at once, so it can assemble claims that span chunks. It’s also one of only two approaches to pass the hardest long-range case in the set: a 150-point noisy lab trend spread across 44 tool-result pages. **Cons** Unlike approach A, where the judge labels each claim as supported, contradicted, or `not_addressed`, B’s extractions are free-form, so nothing in them separates “not covered by this chunk” from “disputed by this chunk”. That shows up as silence being read as a problem: in one case, B rejected a correct response because the extracted evidence had no medication names, and concluded the claims could not be supported. It also doesn’t fully escape the problem it was meant to solve. The final call reads every chunk’s extraction at once, so as responses carry more claims and evidence spreads across more chunks, that single call grows with them. That puts the small judge model back where the article started: reasoning over more context than it can reliably handle in one pass. ### C. Code-executing agent Instead of reading the tool results as raw text, an agent queries them with code. It has exactly one tool: run arbitrary Python against the real tool-result data, which is already loaded in a sandbox as ordinary variables (lists, dicts, tables). For each claim in the response, the agent writes a small snippet, such as filtering rows, counting items, or cross-referencing two fields. The sandbox runs it, and only the short printed output goes back to the agent, so the raw data never enters the model’s context. Once it has checked everything, the agent writes a plain-text summary of what it found, and that summary is all the final judge call ever sees. C · Code-executing agent 1. **Assistant response**The claims the agent must verify. **Full tool-result dataset**Loaded as variables in the sandbox. 2. Query loop **Agent ↔ Python sandbox**The agent writes code. Python queries the full dataset and returns short printed results.Repeat as needed within the step budget 3. **Plain-text evidence summary**The agent summarizes what it checked. 4. **Final judge**Reads the answer and the summary. 5. **Final verdict**One grounding decision. The complete dataset stays in the Python sandbox. The agent sees query results, and the final judge sees only the agent’s summary. ```py def verify_response(response, tool_results): agent = Agent( tools=[run_python_against(tool_results)], system_prompt=CODE_AGENT_SYSTEM_PROMPT, ) summary = agent.run( f"Verify every claim in this response against the underlying data:\n{response}" ) verdict = judge_model.run( FINAL_JUDGMENT_PROMPT, response=response, evidence=summary ) return verdict.is_grounded ``` **Pros** The lowest input-token count of the five (\~5,884 avg), and on the four production-scale test cases, roughly 4.5–25× fewer input tokens than the next-cheapest approach. It never splits the evidence: the code runs against the entire dataset at once, so medication A on page 1 and medication B on page 2 are just two rows in the same Python object. Because it queries the data instead of reading it, its cost follows how much exploration a claim needs rather than how much data exists. That’s also why it handles the 150-point lab trend case, which breaks three of the other four approaches (A, D and E). **Cons** Slower than A and B. Each step in the agent loop is a full round trip: the model writes a snippet, the sandbox runs it, and the model reads the output before deciding what to check next, and those steps can’t run in parallel. More importantly, it only verifies what it decides to query. Its misses are the cases where a later record invalidates an earlier one by ID, date or snapshot: the agent confirms the medication in the medication list and never queries the other tool’s data, where the cancellation lives. Its step budget is also a design risk: a claim that needs a long, many-step investigation could run out of steps before the agent has the full picture. ### D. Embedding-retrieval evidence selection Instead of splitting tool data into arbitrary sequential chunks, embed the response’s claims and the tool-result data, then retrieve only the `top_k` most relevant spans **per claim** before verification. This targets the split-fact problem head-on: retrieval can pull both medication A’s span and medication B’s span into the same evidence set for a single claim, regardless of where they originally sat. D · Embedding retrieval 1. **Assistant response**The answer to verify. **Tool-result records**All available evidence. 2. **Extract atomic claims**Create one list of factual claims. **Embed and index**Prepare searchable evidence once per turn. 3. **Retrieve top-k spans per claim**Selected spans can cross page boundaries. 4. One check per claim **Judge claim 1**Read its retrieved evidence. **Judge claim 2**Read its retrieved evidence. 5. **Combine claim verdicts**Grounded only if every claim is supported. Retrieval selects the top-k spans for each claim, even when they come from different original pages. Every claim is then judged on its selected evidence. ```py def verify_response(response, tool_results): claims = extract_claims(response) index = build_embedding_index(tool_results) # chunk + embed once per turn grounded = {} for claim in claims: relevant_spans = index.search(claim, top_k=3) # can cross chunk boundaries verdict = judge_model.run( PER_CLAIM_PROMPT, claim=claim, evidence=relevant_spans ) grounded[claim] = verdict.is_supported return all(grounded.values()) ``` **Pros** Works well for claims that rest on a few specific facts, and has the lowest output-token cost of the five (\~564 avg), since each per-claim call returns one short verdict. **Cons** 75% accuracy, and its main limitation is choosing k. Claims draw on very different amounts of evidence, and a fixed k, or even a similarity threshold, can’t adapt to that: too small and claims that span many records can’t be verified, too large and the judge wades through irrelevant spans. It also makes by far the most calls of any approach (367.4 on average), because it embeds every record separately, which keeps its latency (11.9s) well above A and B. ### E. Refine / iterative sequential chain Process chunks one at a time, carrying forward a running verdict that gets **revised**, not just OR’d, as each new chunk arrives. Closer to the “refine” pattern used in iterative summarization than to classic map-reduce. This targets approach A’s mechanical-OR blind spot, since a later chunk can walk back an earlier chunk’s incorrect “supported” verdict instead of only ever adding to it. E · Sequential refine 1. **Assistant response**The answer to verify. 2. **Extract atomic claims**One model call creates the claim list. 3. **Initialize per-claim labels**Every claim starts as not\_addressed. 4. Sequential · one chunk after another **Refine the running verdict**Read the next chunk with the previous labels. Revise each claim as new evidence arrives.Carry revised labels into the next step 5. **Final verdict**Grounded only if every final label is supported. Each chunk can upgrade or downgrade earlier labels. The chain carries per-claim verdicts forward, rather than the underlying evidence. ```py def verify_response(response, evidence_chunks): claims = extract_claims(response) # one LLM call: list of atomic claims running_verdict = {claim: "not_addressed" for claim in claims} for chunk in evidence_chunks: # sequential, not parallel running_verdict = judge_model.run( REFINE_PROMPT, claims=claims, evidence=chunk, previous_verdict=running_verdict, ) # can upgrade OR downgrade any claim's verdict return all(v == "supported" for v in running_verdict.values()) ``` **Pros** Its running verdict can walk back an earlier “supported” when a later chunk changes the picture, which a mechanical OR-reduce cannot do. We saw this happen: a later note discontinued “the medication started on 2026-01-10” without naming it, and E downgraded the claim that A’s OR-reduce kept as supported. And unlike D, its call count doesn’t scale with record count: it processes one chunk per call regardless of how many records that chunk contains. **Cons** 75% accuracy, one case more than A, which isn’t enough to call it more accurate. The running verdict carries forward per-claim labels rather than the evidence behind them, so claims that need many records seen together stay out of reach, and so do invalidations that only make sense next to the earlier record’s details. It’s also the slowest and most input-heavy approach of the five (18.0s avg, \~23,759 input tokens), since each refine call depends on the last and none can run in parallel. ## What we measured We ran a 160-run sweep (32 test cases × 5 approaches). The test cases include a category where a later record invalidates an earlier one using only an ID, date or snapshot, such as an order cancelled by order number, a superseded prescription, a medication list that turns out to be an archived snapshot, or vitals from a previous encounter. Approach **Accuracy**Higher is better **Average latency**Lower is better **Average input tokens**Lower is better A**Per-claim map, code reduce** Accuracy72% Average latency5.9 s Average input tokens\~22,622 B**Extractive map, single reduce** Accuracy81% Average latency6.0 s Average input tokens\~18,183 C**Code-executing agent** Accuracy84% Average latency8.6 s Average input tokens\~5,884 D**Embedding retrieval** Accuracy75% Average latency11.9 s Average input tokens\~19,614 E**Refine sequential chain** Accuracy75% Average latency18.0 s Average input tokens\~23,759 All bars start at zero. Scales: accuracy 0–100%; latency 0–20 s; input tokens 0–25,000. View all benchmark values, including output tokens | Approach | Accuracy | Latency | Input tokens | Output tokens | | -------------------------------- | -------- | ------- | ------------ | ------------- | | A: Per-claim map, code reduce | 72% | 5.9 s | \~22,622 | \~2,716 | | B: Extractive map, single reduce | 81% | 6.0 s | \~18,183 | \~812 | | C: Code-executing agent | 84% | 8.6 s | \~5,884 | \~775 | | D: Embedding retrieval | 75% | 11.9 s | \~19,614 | \~564 | | E: Refine sequential chain | 75% | 18.0 s | \~23,759 | \~2,426 | 32 synthetic cases per approach. Latency and token counts are averages; token counts are approximate. No repeated runs or confidence intervals were supplied. ## In Conclusion The split-fact scenario we started with turned out to be a good first test: all five approaches handle it once they stop judging each chunk in isolation. The experiments pointed to two harder problems. The first is claims that have to be assembled from a large evidence set rather than confirmed by one localized fact, where the approaches differ most in accuracy and in cost. The second is records that invalidate earlier ones by reference only. Three of those cases, a cancelled order, a superseded prescription, and an archived snapshot, were missed by all five approaches. - **A (per-claim map, code reduce)** is tied for fastest. It works well when each claim can be confirmed by a fact within a single chunk, and breaks when evidence is spread across a large record set or when a later record invalidates an earlier one by ID only. - **B (extractive map, single reduce)** is tied for fastest and can assemble claims that span chunks, because one final call sees all the extracted evidence. Its free-form extractions can read silence as a problem, and that final call grows as the evidence does. - **C (code-executing agent)** uses the fewest input tokens by a wide margin, especially on the largest cases, because it queries the data instead of reading it. It only verifies what it chooses to query, so it can miss invalidations that live in another tool’s data, and its step budget limits how far it can explore. - **D (embedding retrieval)** works well for claims that rest on a few facts and has the lowest output-token cost. Its weakness is choosing k: a fixed window, even with thresholding, can’t adapt to how much evidence each claim needs. It also makes by far the most calls. - **E (refine)** can walk back an earlier “supported” verdict when a later chunk changes the picture. But it carries labels forward rather than evidence, and it’s the slowest and most input-heavy approach of the five. No approach wins on every axis, so here’s what we’d pick. For grounding checks over large tool results, the code-executing agent is the best value of the five: the highest accuracy in our tests, on par with B, at a fraction of the input tokens, roughly 4.5–25× fewer than the next-cheapest approach on the largest cases. It comes with two limitations. It’s slower than A and B (8.6s against 5.9–6.0s), and it only checks what it decides to query, so it can miss a cancellation or a superseded record that lives in another tool’s data. If latency matters most and your claims usually rest on facts within a single page of results, the per-claim map (A) or the extractive map (B) are fast, simpler alternatives. And if your data has records that invalidate others by reference only, none of these approaches is enough on its own yet. If you’ve built something similar, tried a different chunking strategy or reduce logic, or taken a completely different route, we’d like to hear about it. [Email Guilherme](mailto:guilherme@loka.com). ## References - [RAG Faithfulness — definition and measurement](https://deepchecks.com/glossary/rag-faithfulness/), Deepchecks - [Ragas metrics explained: faithfulness and claim decomposition](https://saulius.io/blog/ragas-rag-evaluation-metrics-llm-judge), Saulius Šlekys - [Self-Correcting RAG: Enhancing Faithfulness via MMKP Context Selection and NLI-Guided MCTS](https://arxiv.org/html/2604.10734), arXiv:2604.10734 - [HalluciNot: Hallucination Detection Through Context and Common Knowledge Verification](https://arxiv.org/pdf/2504.07069), arXiv:2504.07069 - [VISTA: Verification In Sequential Turn-based Assessment](https://arxiv.org/pdf/2510.27052), arXiv:2510.27052 - [awesome-hallucination-detection](https://github.com/EdinburghNLP/awesome-hallucination-detection), EdinburghNLP — curated list of hallucination-detection research - [Summarization with LangChain — Stuff, Map-Reduce, Refine](https://medium.com/@abonia/summarization-with-langchain-b3d83c030889), Abonia Sojasingarayar — background on the refine-chain pattern behind Approach E