> ## Documentation Index
> Fetch the complete documentation index at: https://docs.roark.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge base grounding

> Ask questions your knowledge base answers, and check your agent stays faithful to it

## Why this is a common failure point

Agents backed by a knowledge base fail in two opposite ways. They make things up: a price, a policy, a menu item that isn't there, stated with total confidence. Or they play it too safe and say "I don't know" to questions the knowledge base answers plainly. Both look like reasonable conversation, and both cost you: one misleads callers, the other sends them to a human.

## How Roark tests it

Knowledge base grounding runs callers who ask questions your knowledge base can answer, then checks every claim and offer the agent made against the source. It scores both failure directions separately, so an agent that never hallucinates but never answers either can't hide behind a good grounding score.

***

## Setting it up

Pick the knowledge bases to check against (leave it empty to use every knowledge base in the project), then attach the flows that ask the questions.

***

## What it measures

The template seeds these, and you can add or remove metrics in **Advanced** before running.

| Measure                              | What it tells you                                                                            |
| :----------------------------------- | :------------------------------------------------------------------------------------------- |
| **Knowledge Base Grounding (check)** | How faithful the agent stayed to the knowledge base, 1 to 5. The check passes at 3 or above. |
| **Ungrounded Claim**                 | Statements or offers that conflict with, or are not supported by, the knowledge base.        |
| **Missed Answer**                    | Questions the knowledge base could answer that the agent deflected or got wrong.             |

***

## What to look for

* **Read both scores together.** High grounding with many missed answers means the agent is too cautious, not accurate.
* **Ungrounded offers cost the most.** A made-up discount or a menu item you don't sell becomes a promise the business has to handle.
* **Write flows around real questions.** Pull them from your support queue so the test reflects what callers actually ask.

***

## Over the API

Run it with `POST /v1/simulation/run` and `"template": "knowledge-base-grounding"`. `GET /v1/simulation/template` lists what each template accepts.
