Attach a KB
Set retrieval parameters (optional)
Most agents work fine with defaults. See tuning below.
How retrieval works
At each user turn:- The agent’s STT produces a transcript of what the caller said.
- The platform embeds that turn (plus a small window of conversation context).
- It performs a vector similarity search across all attached KBs.
- The top top_n chunks (default 5) are inserted into the LLM context for that turn.
- The LLM generates a response that can quote or paraphrase the chunks.
Tuning retrieval
| Lever | Default | When to change |
|---|---|---|
top_n | 5 | Increase to 8-10 if answers are missing context. Decrease to 3 if the LLM keeps quoting irrelevant snippets. |
| Multiple KBs | One | Split into multiple KBs when the content covers very distinct domains (e.g. Product FAQ + Returns Policy) so retrieval is more focused. |
When implicit retrieval isn’t enough
For most use cases, just attaching a KB is sufficient. Reach for explicitknowledge_base tools (see Tools) when:
- You want the agent to announce that it’s looking something up
- You want different KBs queried for different question types (“for product questions, query Product FAQ; for policy questions, query Policy KB”)
- You want a higher
top_nfor some questions than the default
Anti-patterns
Putting too much in one KB. If your KB has 10,000 chunks covering five unrelated domains, retrieval will be noisy. Split it. Stale content. Embeddings are recomputed only when sources are added or updated. If your product changes, refresh the KB. Treating the KB as a memory store. KBs are for static reference content. For per-call state (the caller’s name, what they asked earlier), rely on the conversation context, not retrieval.Pairing KBs with prompts
If you instruct the agent in the system prompt to “only answer from the knowledge base — don’t make things up”, you’ll get fewer hallucinations but more “I don’t know” responses. Conversely, telling it to “use the knowledge base when relevant, otherwise answer from general knowledge” makes it more flexible but also more prone to confident wrong answers. For most production agents, the safer instruction is:When the caller asks a factual question, prefer the knowledge base. If you can’t find an answer in the knowledge base, say “I don’t have that information — let me get someone who does” and use the transfer tool.

