Skip to main content
The Knowledge class gives agents the ability to search a corpus of documents for information beyond their model’s training data and cut-off date. Instead of hardcoding information in prompts or relying solely on their model’s training set, agents can dynamically retrieve the most relevant and latest information. The Knowledge class uses vector embeddings to find the most relevant document chunks based on semantic similarity.
Create a searchable knowledge base and give an agent access to it as a tool:

Adding Documents

From Text

Add text directly to the knowledge base:

From URLs

Load documents from the web:
Supported formats (via text extraction):
  • Plain text
  • Markdown
  • HTML
  • PDF (if markitdown is installed)
  • Word documents (if markitdown is installed)
  • Many more formats via markitdown

Configuration Options

Key parameters:
  • model - Embedding model for vector search. Default: embed-english-v3
  • max_results - Number of top results to return. Default: 10
  • max_distance - Similarity threshold (0.0 = identical, 1.0 = completely different). Default: 0.2
  • max_knowledge_size - Maximum characters in the returned context. Default: 4096
  • chunker - Strategy for splitting documents into chunks

Storage Backends

In-Memory Storage (Default)

Stores everything in memory. Simple but not persistent:

Database Storage

For persistent storage across restarts:

Use Knowledge as a Tool

Give agents explicit control over when to search: