Skip to content

Knowledge Base 🟑 BETA

A knowledge base is a bot-scoped set of indexed folders that a session activates so retrieval can add grounded context to the system message.

Developer guide map

Quick Overview

USE KB activates a folder by name; CLEAR KB deactivates it. Active associations live in session_kb_associations and are read only for the current session and bot. The collection name is produced by KbTenantScope::collection_name, which pins every query to the bot's tenant.

Operation Keyword / surface State touched
Activate a folder USE KB Active KB association
Deactivate CLEAR KB Removes one or all associations
Crawl a site USE WEBSITE Active website association
Query rag-mode retrieval System message context block

Key Capabilities

Structured Docs search. Saved Docs documents are indexed in a separate, process-local structure-aware index. GET /api/docs/kb/search?q=<text>&limit=<n> returns citation identity (document_id, file, version, source_ref, section, score) for documents the caller may read, never document text. In chat, a question about a saved document appends up to three citation-only lines to the system message for an authenticated user; anonymous turns get none. A SAVED DOCUMENT CITATIONS directive precedes those lines: it tells the model the records prove the documents exist, that it must cite the exact file name, version, section and page when a record matches the question, and that it must not claim a document is missing from Drive. Only identity fields are supplied β€” never document text. See Document Indexing.

Tenant Isolation

Resolution contract

get_active_kbs resolves the bot's branch_id from bots, builds KbTenantScope, and refuses to run when no verified scope exists. Search applies filter_for_bot(Some(bot_id)), then kb_chunk_is_authorized rechecks the payload stamp and current ACL for each point.

Scope of the guarantee

Layer Enforcement
Collection name Derived from bot + branch, not from user input.
Query filter Server-resolved bot id; no scope β†’ no search.
Payload Stamped scope_bot_id / bot_id must match; foreign stamps rejected.
ACL Current verdict consulted when a verifier is installed.

Configuration

Key Effect
rag-mode Retrieval strategy, see Retrieval and RAG.
mention-class Whether KBs and websites are consulted.
embedding-url, embedding-model Vector generation for indexed records.

Limits

  • Collections are session-scoped; a new session must activate them again.
  • Documents are whole-file records with no chunking, so long files lose precision.
  • The Docs citation index is process-local and returns identity only.
  • Retrieval refuses to run without a verified bot scope.

Performance Tips

Activate only the collections a conversation needs: each active collection is searched separately and its results merged. Keep folders focused so retrieved records stay relevant. Re-index changed files rather than rebuilding everything.

Learn More