Skip to main content
The 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.
Returns the most relevant document chunks as formatted text.

get_document_count

Returns the number of documents in the knowledge base.
Useful for the agent to understand the scope of available knowledge.

Combining with Other Tools

The knowledge toolkit works alongside other tools:
The agent can call search_knowledge to find information and get_current_date for context, combining results in its response.
For a fully automatic approach where the agent doesn’t need to decide when to search, see KnowledgeMiddleware instead.