Knowledge Tools
KnowledgeTools provide intelligent search and analysis capabilities over knowledge bases with reasoning integration.
Prerequisites
The following example requires the agno, fastembed, openai, and qdrant-client libraries. It connects to Qdrant on localhost:6333.
uv pip install agno fastembed openai qdrant-client
docker run -d --name qdrant -p 6333:6333 qdrant/qdrant:latestSet your OpenAI API key:
export OPENAI_API_KEY=***Example
The following agent can search and analyze knowledge bases:
from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIChat
from agno.tools.knowledge import KnowledgeTools
from agno.vectordb.qdrant import Qdrant
from agno.vectordb.search import SearchType
knowledge = Knowledge(
vector_db=Qdrant(
collection="knowledge_tools_demo",
url="http://localhost:6333",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
knowledge.insert(url="https://docs.agno.com/llms-full.txt")
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[KnowledgeTools(knowledge=knowledge)],
markdown=True,
)
agent.print_response("How do I build a team of agents in Agno?", stream=True)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
knowledge | Knowledge | - | Knowledge base instance (required). |
enable_think | bool | True | Enable reasoning capabilities. |
enable_search | bool | True | Enable knowledge search functionality. |
enable_analyze | bool | True | Enable knowledge analysis capabilities. |
instructions | Optional[str] | None | Custom instructions for knowledge operations. |
add_instructions | bool | True | Whether to add instructions to the agent. |
add_few_shot | bool | False | Whether to include few-shot examples. |
few_shot_examples | Optional[str] | None | Custom few-shot examples. |
all | bool | False | Enable all functionality. |
Toolkit Functions
| Function | Description |
|---|---|
think | Scratchpad for reasoning about the question and planning searches. |
search_knowledge | Search the knowledge base for relevant information. |
analyze | Record the model's analysis of the retrieved documents in session state. |
Search identity and reasoning notes
search_knowledge forwards RunContext.user_id to the knowledge search. Results therefore follow the knowledge store's configured identity scope. think and analyze record the model's supplied reasoning notes in session state; they do not independently verify the documents or the model's claims.