← Back to Dashboard

Knowledge Bases

Document ingestion, chunking, and RAG retrieval for your AI agents

Table of Contents

Overview

Non-technical summary: Knowledge bases are like filing cabinets for your AI agents. You put documents in them — policies, product docs, FAQs, anything — and agents can search through them to find answers. Instead of making things up, agents pull real information from your documents. This is called RAG (Retrieval-Augmented Generation).

The Knowledge Bases page (KnowledgeBasePage) manages document collections that power RAG retrieval for your agents. It provides a card-based list view of all knowledge bases, a two-panel detail view showing documents and their chunks, inline editing capabilities for both documents and chunks, and integration with the Knowledge Import Wizard for ingesting content from multiple sources.

Knowledge bases are organization-aware — they can be scoped to a specific client organization for data isolation, or kept internal to your organization.

How It Works

  1. Create a knowledge base — Give it a name, description, and optionally assign it to a client organization.
  2. Import documents — Use the import wizard to add content from GitHub, Google Drive, SharePoint, websites, or direct file uploads.
  3. Automatic chunking — Documents are automatically split into smaller text segments (chunks) optimized for retrieval.
  4. Assign to agents — Link knowledge bases to agents so they can search them when answering questions.
  5. Agents query at runtime — When an agent needs information, it searches the knowledge base and the most relevant chunks are included in its prompt context.

Key Concepts

RAG (Retrieval-Augmented Generation)

RAG is the technique of retrieving relevant documents before generating a response. Instead of relying solely on the LLM's training data, the agent searches your knowledge base for specific, up-to-date information and uses it to form accurate answers.

Documents vs. Chunks

A document is a source file you import (PDF, markdown, web page, etc.). A chunk is a smaller segment of that document — typically a few paragraphs — that the retrieval system can match against queries. Smaller chunks allow more precise retrieval but use less context per match.

Organization Scoping

Knowledge bases can be assigned to a client organization via clientOrgId. This ensures data isolation — agents in Org A cannot access Org B's knowledge bases. When the org context switcher is active, only relevant KBs are shown.

Creating Knowledge Bases

FieldRequiredDescription
NameYesDescriptive name (e.g., "Product Documentation Q1 2026")
DescriptionNoWhat this knowledge base contains and its purpose
OrganizationNoAssign to a client org for data isolation, or leave as internal
POST /api/engine/knowledge-bases
Content-Type: application/json

{
  "name": "Customer Support Playbook",
  "description": "Standard responses, escalation procedures, refund policies",
  "orgId": "default-org-id",
  "clientOrgId": "client-abc123"
}

Detail View

Clicking a knowledge base card opens the detail view with:

Documents

Documents are the source files imported into a knowledge base. Each document shows:

PropertyDescription
NameDocument filename or title (editable inline)
Source TypeWhere the document came from (upload, github, url, etc.)
MIME TypeFile format (text/markdown, application/pdf, etc.)
SizeFile size in bytes or KB
Chunk CountNumber of chunks generated from this document
StatusProcessing status (pending, processed, error)

Documents can be renamed via inline editing and deleted individually. Deleting a document removes all its chunks.

Deleting a document is permanent. All associated chunks will be removed and cannot be recovered. Re-import the document if needed.

Chunks

Select a document to view its chunks in the right panel. Each chunk displays:

When to edit chunks: If an agent gives incorrect answers, check the source chunks. You might find OCR errors from PDF extraction, formatting artifacts, or ambiguous text that needs clarification. Editing chunks directly improves retrieval quality without re-importing the entire document.
// Update a chunk's content
PUT /api/engine/knowledge-bases/{kbId}/chunks/{chunkId}
Content-Type: application/json

{ "content": "Updated chunk text with corrected information..." }

// Delete a chunk
DELETE /api/engine/knowledge-bases/{kbId}/chunks/{chunkId}

Import Wizard

The Import Wizard (KnowledgeImportWizard) is accessible from both the list view and detail view. It supports importing content from:

Import jobs are tracked asynchronously — you can view their progress in the Import Jobs section of the detail view.

Agent Access

The Agent Access card in the KB detail view controls which agents can search and retrieve information from this knowledge base.

For non-technical users: Think of agent access like sharing a folder — you pick which agents are allowed to look inside this knowledge base. An agent without access simply can't see or search the documents in it.

How to Assign Agents

  1. Open a knowledge base by clicking on it from the list.
  2. Scroll to the Agent Access card (below the stats).
  3. Click on agent names to toggle their access — selected agents are highlighted with a checkmark.
  4. Click Save Agent Access to apply changes. Click Reset to undo unsaved changes.

How It Works Technically

Each knowledge base has an agentIds array stored in the database. When an agent performs a RAG search via GET /knowledge-bases/search?agentId=xxx, only knowledge bases where the agent's ID is in the agentIds array are searched.

Updating agent access calls PUT /knowledge-bases/:id with the new agentIds array. Changes take effect immediately — the agent will have access on its very next query. No agent restart is required.

PUT /knowledge-bases/:id
{
  "agentIds": ["agent-uuid-1", "agent-uuid-2"]
}
Important: If an agent is not assigned to any knowledge base, it cannot use RAG retrieval and will rely solely on its training data and conversation context. Always assign relevant KBs to agents that need them.

Automatic Assignment (Onboarding)

When a new agent is created, knowledge bases are automatically assigned based on org context:

Agent TypeGets Access To
Client org agentAll KBs belonging to their client organization
Internal agentAll KBs NOT belonging to any client organization (shared/internal KBs)

If you add new knowledge bases after agents are already running, use the "Sync Knowledge" button on the agent's Deployment tab to trigger auto-assignment for that agent.

Auto-Assign API

POST /knowledge-bases/auto-assign/:agentId
Body: { "clientOrgId": "org-uuid" }  // optional
Response: { "assigned": ["kb-id-1", "kb-id-2"], "count": 2 }

Only adds new assignments — does not remove existing ones.

Organization Scoping

Agent access respects organization boundaries. If a knowledge base belongs to a client organization, only agents assigned to that organization can be given access. This ensures data isolation in multi-tenant deployments.

API Reference

EndpointMethodDescription
/api/engine/knowledge-basesGETList all knowledge bases
/api/engine/knowledge-basesPOSTCreate a new knowledge base
/api/engine/knowledge-bases/{id}GETGet KB detail with documents and stats
/api/engine/knowledge-bases/{id}PUTUpdate KB name, description, org assignment
/api/engine/knowledge-bases/{id}DELETEDelete KB and all documents/chunks
/api/engine/knowledge-bases/{id}/documents/{docId}PUTRename a document
/api/engine/knowledge-bases/{id}/documents/{docId}DELETEDelete a document and its chunks
/api/engine/knowledge-bases/{id}/documents/{docId}/chunksGETList chunks for a document
/api/engine/knowledge-bases/{id}/chunks/{chunkId}PUTUpdate chunk content
/api/engine/knowledge-bases/{id}/chunks/{chunkId}DELETEDelete a single chunk

Best Practices

Troubleshooting

No chunks appear after importing

The document may still be processing. Check the import jobs section for status. If the status is "error", the file format may not be supported or the content couldn't be extracted.

Agent can't find information that's in the KB

Check: (1) Is the KB assigned to the agent? (2) Are the relevant chunks well-formed? (3) Is the query phrasing similar to the chunk content? Try editing chunks for clarity.

Knowledge base doesn't appear in the list

Check the org context switcher — you may be viewing a different organization's KBs. Clear the org filter to see all knowledge bases.

Deleting a knowledge base removes all documents and chunks permanently. This action cannot be undone. Consider exporting important content before deletion.
AgenticMail Enterprise Documentation Report an issue