KnowledgeToolkit provides agents with tools to search a knowledge base on demand. Unlike the automatic KnowledgeMiddleware (which retrieves context before every model call), the toolkit lets the agent decide when to search.
When to Use
Use
KnowledgeToolkit when:
- The agent should decide whether a search is needed
- Not every user message requires knowledge retrieval
- The agent needs to search multiple times with different queries
Setup
Provided Tools
The toolkit exposes two tools to the agent:search_knowledge
Searches the knowledge base with a natural language query.get_document_count
Returns the number of documents in the knowledge base.Combining with Other Tools
The knowledge toolkit works alongside other tools:search_knowledge to find information and get_current_date for context, combining results in its response.