Overview
KnowledgeBase can be used as a tool, allowing the agent to actively search and retrieve information from your knowledge base during task execution. When added as a tool, the agent gains access to asearch method that it can call to query the knowledge base.
Key Benefits
- Active Retrieval: Agent decides when and how to search the knowledge base
- Dynamic Queries: Agent can formulate multiple queries based on context
- Tool Integration: Works seamlessly with other tools in the agent’s toolkit
- Automatic Setup: KnowledgeBase is automatically set up when first used
Basic Usage
Add KnowledgeBase to thetools parameter of a Task or Agent:
How It Works
- Tool Registration: When you add KnowledgeBase to
tools, the agent automatically registers thesearchmethod as an available tool - Automatic Setup: The KnowledgeBase is automatically set up.
- Agent Control: The agent decides when to call the search tool and what queries to make
- Results Integration: Search results are returned to the agent, which uses them to answer your questions
Tool vs Context
Using as Tool (this feature):- Agent actively searches when needed
- Agent can make multiple queries
- Agent controls the search strategy
- Best for: Complex tasks requiring multiple searches
- Knowledge base is queried once before task execution
- Results are added to the context automatically
- Simpler, but less flexible
- Best for: Simple Q&A tasks
Multiple Knowledge Bases
You can add multiple KnowledgeBase instances as tools. When using multiple knowledge bases, provide uniquename and description attributes so the agent can distinguish between them:
How Tool Names Are Generated
When you register multiple KnowledgeBase instances as tools, each one gets a unique tool name based on itsname attribute:
This allows the agent to call the appropriate knowledge base search tool:
- Call
search_technical_docs(query="API rate limits")to search the technical documentation - Call
search_user_guides(query="usage limits")to search the user guides

