---
title: "Controlling Hallucinations via Model Grounding Flags and Thresholds"
date: "2026-11-27T08:06:00+07:00"
description: "Grounding as an engineering control: Google Search grounding, grounding with private data, retrieval thresholds, citation verification, and a layered defense that treats hallucination as a measurable rate rather than a vibe."
author: "AI Assistant"
image: "https://blog.redlinesoft.net/images/post/grounding-flags-hallucination-thresholds.jpg"
alt: "Answer card tethered to source documents by visible threads"
tags: ['google-adk', 'grounding', 'hallucination', 'reliability', 'rag']
---

Hallucination is not a defect you patch; it is a rate you drive down with controls. Some of those controls are model settings — whether the model must search before answering, how confident it must be that a search is worth doing, whether an answer is allowed out without citations. Others are architecture: where the facts come from, and what you check before the user sees the text.

This article is about those controls specifically — the flags and thresholds available when you ground an ADK agent, and how to combine them into a system where "made it up" is an observable, alertable event.

## What grounding is in ADK

ADK documents three distinct approaches, and choosing between them is most of the battle:

1. **Google Search grounding** — the agent calls out to live web search for current facts (news, prices, releases). Answers carry `grounding_metadata`: the search queries used, the pages retrieved, and which spans of the answer cite which pages.
2. **Grounding with Search** — the same mechanism pointed at *your* indexed datastore: internal documents, support corpora, policy wikis. Answers cite your sources.
3. **Agentic RAG** — the agent reasons about *how* to search: constructing queries, filters, and rerank steps dynamically instead of retrieving once and hoping.

The third is the most capable and the hardest to constrain. If you are starting out, ship 1 and 2 with citation verification before you graduate to agentic retrieval.

## The flags that change behaviour

**Tool availability is a flag.** An agent with `google_search` in its `tools` list can choose to search; the instruction decides whether it *may answer without* searching:

```python
from google.adk import Agent
from google.adk.tools import google_search

agent = Agent(
    name='analyst',
    model='gemini-3.8-flash',
    instruction="""You answer only from retrieved sources.
For any claim about a date, a number, a person, or a current event you MUST
call google_search first. If the retrieved sources do not cover the question,
say so and stop — do not fill the gap from memory.""",
    tools=[google_search],
)
```

That instruction converts an open-ended judgement ("should I search?") into a rule keyed on claim type, which models follow far more reliably.

**Retrieval mode and score threshold.** Where the API exposes dynamic retrieval, the model can decide per-request whether a search is warranted, using a confidence threshold: below the threshold it answers directly, above it, it searches. Raise the threshold and you get fewer, better-targeted searches at the cost of more ungrounded answers; lower it and you get exhaustive searching with more latency and cost. This is a single number you should tune against your measured hallucination rate, not a default you inherit.

**Structured output as a hard gate.** Pair grounding with a schema so citations are machine-checkable rather than prose:

```python
from pydantic import BaseModel

class GroundedAnswer(BaseModel):
    answer: str
    source_urls: list[str]
    unsupported_claims: list[str]

# response_mime_type='application/json', response_schema=GroundedAnswer
```

Forcing the model to enumerate `source_urls` (and, importantly, any claim it could *not* support) makes verification a programmatic step: if `source_urls` is empty on a factual question, the answer doesn't ship.

**Safety thresholds are a different axis.** Harm-category thresholds block unsafe *content*; they say nothing about factual accuracy. Teams that conflate the two end up with answers that are polite and wrong.

## Thresholds you should actually be measuring

| Control | Too low | Too high | Tune on |
|---|---|---|---|
| Dynamic retrieval score | Never searches → ungrounded answers | Searches on every trivial turn → cost/latency | Hallucination rate on a labelled set |
| Citation coverage required | Answers ship with no support | Model refuses harmless questions | Refusal rate on answerable questions |
| Answer-without-search policy | Freewheeling invention | Latency on simple lookups | p95 latency + error rate |
| Rerank cutoff | Junk context reaches the model | Empty context on niche queries | Retrieval precision/recall |

Each row is a knob with a trade-off and a measurable. That framing is the whole discipline: no knob is "set and forget", every knob has a metric pair, and you watch both.

## A layered defense in depth

Grounding flags are layer three of five:

1. **Prompt structure.** "Cite every factual claim; say 'not found' otherwise." Cheap, effective, not sufficient alone.
2. **Retrieval quality.** Chunking, metadata filters, reranking. Garbage in context produces plausible-sounding garbage out — grounding cannot rescue a bad index.
3. **Grounding flags and thresholds.** Mandatory search for factual claim classes, dynamic retrieval thresholds, citation requirements.
4. **Programmatic verification.** Post-generation checks: every URL in `source_urls` must be in the retrieved set; numeric claims must appear (or be derivable) in retrieved text; if verification fails, either regenerate with the gap highlighted or refuse.
5. **Evaluation and monitoring.** A labelled set scored for faithfulness (is each claim supported?) plus production sampling of traces. Track *unsupported claim rate* as a first-class SLO with an alert.

### Wiring verification into the turn

```python
def verify(answer: GroundedAnswer, retrieved: set[str]) -> tuple[bool, list[str]]:
    bad = [u for u in answer.source_urls if u not in retrieved]
    if bad:
        return False, [f'cites non-retrieved source: {u}' for u in bad]
    return True, []

ok, problems = verify(parsed_answer, retrieved_urls)
if not ok:
    # regenerate with the flagged gaps, or refuse explicitly
    ...
```

Note what verification can and cannot do: it catches *unsupported* citations and missing references; it cannot prove the prose is faithful to the cited page. For high-stakes domains, add a second model pass that checks each sentence against its cited snippet — a cheap LLM judge, not a human, for the first gate.

## Failure modes to expect

- **Grounding theatre.** The model cites sources that exist but don't support the sentence. Detection requires span-level checking, not URL presence.
- **Search-then-ignite.** The model searches, ignores the results, and answers from memory. Compare the answer against retrieved text, not against the search call log.
- **Threshold drift after prompt edits.** Loosening the instruction quietly moves your hallucination rate; re-run the eval on every instruction change.
- **Latency creep.** Mandatory search adds a round trip. Measure the grounding-on and grounding-off TTFT separately so the trade is explicit.

## Takeaways

- Grounding is a control surface: tool availability, mandatory-search rules for specific claim types, retrieval thresholds, and citation schemas.
- Every threshold is a two-metric dial — tune hallucination rate *against* refusal rate, cost, and latency.
- Structure citations as data (`source_urls`, `unsupported_claims`) so verification is code, not judgement.
- Layer defenses: prompt → retrieval quality → grounding flags → programmatic verification → monitored unsupported-claim rate.
- Treat "supported claim rate" as an SLO with alerts, and re-run the eval on every instruction change.

## Further reading

- [Enterprise RAG patterns: naive vs agentic RAG](/blog/agentic-rag-zero-index-data-retrieval-gemini-3)
- [Faithfulness and groundedness evaluation](/blog/agent-auditor-observability-compliance-gemini-3)
- [AI agent threat modeling: prompt injection and exfiltration](/blog/ai-security-prompt-injection)
- [System instruction optimization for tool calling](/blog/system-instruction-meta-prompting-deterministic-tool-calling)
