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

# Test your knowledge base

> Verify retrieved passages and Anam persona answers with repeatable questions, source checks, and tests for exceptions and document updates.

Check both the passages returned by search and the answers your persona gives. A successful upload or a relevant document appearing in search is only part of the check.

## Before you test

* Upload documents and wait for them to reach [`READY`](/docs/personas/knowledge/uploading-documents#monitoring-upload-progress).
* [Connect a knowledge tool](/docs/personas/knowledge/tools) to the persona and confirm its selected folders.
* Record the document revisions, folder IDs, and document IDs, along with the persona's prompt, model, and tool configuration.
* Choose questions with expected answers supported by your sources. Keep the other settings and question script constant when measuring a document change.

## Inspect retrieved passages

Search a knowledge group directly to check the evidence available in that folder. Use the [search knowledge group API](/docs/api-reference/knowledge/search-knowledge-group) from a terminal or your server, with `ANAM_API_KEY` and `KNOWLEDGE_GROUP_ID` set in your environment:

```bash theme={"system"}
curl --fail-with-body --request POST \
  "https://api.anam.ai/v1/knowledge/groups/${KNOWLEDGE_GROUP_ID}/search" \
  --header "Authorization: Bearer ${ANAM_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data '{"query":"What is the return period for UK purchases?","limit":5}'
```

Replace the example question with one about your documents. The response is an array of matching passages. For each relevant result, check:

| Field                       | What to check                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------- |
| `documentId` and `filename` | The passage comes from the intended file and revision. Compare the ID with your upload record.     |
| `content`                   | The fact is complete, with the relevant region, conditions, exceptions, and source details.        |
| `chunkIndex`                | Record this with the document ID when reporting a missing or broken passage.                       |
| `score`                     | A similarity score helps rank results; it does not establish that a fact is correct or applicable. |

For a document update, search for a distinctive changed fact and inspect the returned text. Check that superseded document IDs are no longer returned. For PDFs and tables, compare the passage with the original page for missing columns, units, or footnotes.

Retrieve pricing, eligibility, and procedure sections separately. Check that each passage includes the restrictions needed to interpret it, even when the rest of the document is absent. If a rule is missing, [keep it beside each affected fact or instruction](/docs/personas/knowledge/preparing-documents#keep-critical-rules-with-the-facts) and test again.

A direct search checks one folder with your chosen query. The persona may choose a different query or search several folders through its tools, so also test the conversation itself.

## Test persona answers

Start a fresh session after changing documents or configuration. Check that the persona uses the intended knowledge tool, then compare its answer with the approved source. [Knowledge tool events](/docs/personas/knowledge/tools#monitoring-knowledge-tool-calls) can help confirm that a search ran or failed; an event reporting completion alone does not establish answer quality.

Use this fictional test set as a starting point and adapt the expected behavior to your sources:

| Question or turn                                      | Expected behavior                                                                        |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| “Can I get a refund?”                                 | Asks for eligibility details required by the policy, such as purchase date and region.   |
| “I bought it 40 days ago.”                            | Applies the documented deadline and exceptions; asks for any remaining required details. |
| “Actually, the purchase was in another region.”       | Reassesses the region while retaining the order age.                                     |
| “Is my issue guaranteed to be resolved in two hours?” | Distinguishes an initial response target from a resolution promise.                      |
| Ask about two products with similar names.            | Uses the facts for the requested product and version.                                    |
| Ask for a detail absent from the documents.           | Acknowledges the missing information rather than inventing an answer.                    |
| Ask about a recently changed policy.                  | Uses the replacement's rule, scope, and effective date.                                  |
| Ask how to perform a documented update.               | Includes prerequisites, ordered steps, and completion checks from the source.            |

Run the first three questions as a conversation to test how the persona handles changed context. Repeat important cases in fresh sessions and record failures as well as successes.

## Diagnose a failed check

| What you observe                                                 | What to inspect next                                                                                                                                                                                                              |
| ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| No results or the wrong document                                 | Check processing status, folder IDs, tool attachments, and the search query.                                                                                                                                                      |
| The right file, but missing conditions or unreadable text        | Compare extraction with the original; [keep facts complete](/docs/personas/knowledge/preparing-documents#write-clear-complete-facts) and [preserve formatting](/docs/personas/knowledge/preparing-documents#preserve-formatting-and-steps). |
| Repeated or contradictory passages                               | [Remove duplication](/docs/personas/knowledge/preparing-documents#remove-duplication) and [resolve source conflicts](/docs/personas/knowledge/preparing-documents#handle-conflicting-information).                                          |
| An old rule still appears                                        | Check exact files, active document IDs, and [replacement steps](/docs/personas/knowledge/uploading-documents#replace-an-existing-document).                                                                                            |
| Direct search is correct, but the persona gives the wrong answer | Check the persona's chosen tool, folders, query, and returned evidence where available, then inspect its [prompt and tool instructions](/docs/personas/llms/prompting-guide#tool-calling-definitions).                                 |
| Internal material appears in a public answer                     | Review every attached folder and enforce the intended [knowledge scope](/docs/personas/knowledge/setup#set-the-knowledge-scope).                                                                                                       |

If the evidence used in the conversation is correct but the answer contradicts it, investigate answer generation and application rules. Decisions that must follow fixed rules may need validation in your application before an answer is delivered.

## Record your results

Keep a test record outside the searchable knowledge folders. Distinguish a passage from a direct API test from evidence captured during the persona's actual tool call.

Copy this record for each test case:

| Field                | Record                                                                                        |
| -------------------- | --------------------------------------------------------------------------------------------- |
| Test name            | Updated policy, exception, missing detail, or another case.                                   |
| Question and context | The question and relevant earlier conversation turns.                                         |
| Expected answer      | The applicable rule and its source location.                                                  |
| Retrieved evidence   | Passage text, document ID, and whether it came from direct search or the persona's tool call. |
| Actual answer        | The persona's response.                                                                       |
| Result               | Pass or fail, with the reason and any follow-up action.                                       |

Record the settings and revisions with each test run. If measuring performance, track search duration separately from the time the persona takes to answer. One successful run does not prove reliability.

## Next steps

Complete the [upload checklist](/docs/personas/knowledge/upload-checklist). Correct unresolved failures and repeat the affected tests before releasing the updated knowledge to users.
