Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Setting up the knowledge base

Provision retrieval grounding: a managed collection on the platform, or your own HTTP search endpoint. Includes field/slot contracts and verification steps.

Context — Assumes Knowledge base & retrieval (the two implementations and how a retrieval runs). This guide is the provisioning walkthrough for each, plus how to verify grounding actually works.

YAML examples follow manifest schema 9.10.0. Manifest and content shapes are schema-versioned and differ across runtime versions — see Versioning & compatibility.

Choosing an implementation

Decide once per agent — agent_config.search holds exactly one:

  • collections if your corpus lives in a managed collection on the platform. You define the search as a list of typed fields; the agent produces each field's text (and embeds the vector fields) and queries the collection — dense, keyword, or a hybrid of both.

  • external if search already exists in your stack (Elasticsearch, a RAG service, a vendor API) or you need custom ranking. The agent sends conversation context; you return snippets.

Option A: managed collections

1. Create the collection

Build a collection in a platform database and load your chunks (see the iai collections command reference). A collection can carry several vector slots and, optionally, a full-text index — the agent can query whichever of these you configured. Each vector slot has an embedding model bound to it at creation time — the manifest never re-declares that model.

The search is a list of fields. Each field names the prompt that turns the conversation into its text, and a type:

  • str — the text is sent as a keyword query.

  • vector — the agent embeds the text using the model bound to the target slot and matches it against that slot.

One field runs a single search; several fields run each as its own lane and fuse the results. A field searches the slot named by name, or by slot when you want several differently-prompted fields fused on one slot.

Results reach the model with their full payload: every metadata key you stored on a chunk is rendered alongside its text, so a custom schema (prices, URLs, dates…) is usable context, not just the chunk body.

Authentication uses the agent's existing platform keys — no extra credentials, and the organization and project are resolved automatically at startup.

Startup describes the live collection and validates the declared fields against it — a vector field targeting a slot that doesn't exist, a slot with no bound embedding model, or a str field on a collection without full-text enabled all fail boot with an error naming the problem.

Option B: external search endpoint

1. Implement the endpoint

One POST route; request and response contracts are fixed (full details in Knowledge base & retrieval):

Hard requirements: respond within the configured timeout (default 5s); return a bare JSON array of strings; treat messages as most-recent-last. Anything else — envelope objects, non-200s, slow responses — makes the retrieval soft-fail (the turn proceeds ungrounded).

2. Declare it

Verifying grounding (both options)

  1. Boot check — a slot/collection mismatch (collections) fails startup; read the error, it names the problem.

  2. Ask a question only the corpus can answer ("what exactly happens if I cancel 12 hours before pickup?"). A grounded reply cites specifics from your documents; an ungrounded one generalises.

  3. Inspect the trace — retrieval appears in the turn's trace with the query text and returned snippets; see Observability.

  4. Test the soft-fail — take the KB down and confirm the agent still answers (from prompt + history) while logs show retrieval warnings. That's the designed behaviour; alert on the warning rate, not the turn failure (there isn't one). See Troubleshooting.

Operational notes

  • Corpus hygiene beats limit/top_k tuning: wrong-answer regressions are usually stale or contradictory documents. Raise the result count only when answers visibly miss available context — every extra snippet costs prompt space on every retrieval.

  • Fused searches: min_score and exact interact with fusion_k and the number of fields — see the field table in Knowledge base & retrieval before tuning either.

Last updated

Was this helpful?