Knowledge Tools
Give an Agent `think`, `search_knowledge`, and `analyze` tools to query and evaluate results from a Knowledge base before responding.
The KnowledgeTools toolkit enables Agents to search, retrieve, and analyze information from knowledge bases. This toolkit integrates with Knowledge and provides a structured workflow for finding and evaluating relevant information before responding to users.
The toolkit implements a "Think → Search → Analyze" cycle that allows an Agent to:
- Think through the problem and plan search queries
- Search the knowledge base for relevant information
- Analyze the results to determine if they are sufficient or if additional searches are needed
This approach significantly improves an Agent's ability to provide accurate information by giving it tools to find, evaluate, and synthesize knowledge.
The toolkit includes the following tools:
think: A scratchpad for planning, brainstorming keywords, and refining approaches. These are explicit tool notes. Your application controls their visibility in events, stored messages, reasoning displays, and logs.search_knowledge: Executes queries against the knowledge base to retrieve relevant documents.analyze: Evaluates whether the returned documents are correct and sufficient, determining if further searches are needed.
Setup
In an activated virtual environment:
uv pip install -U agno openai lancedb beautifulsoup4
export OPENAI_API_KEY="your_api_key"
mkdir -p tmpExample
Here's an example of how to use the KnowledgeTools toolkit:
from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIResponses
from agno.tools.knowledge import KnowledgeTools
from agno.vectordb.lancedb import LanceDb, SearchType
# Create a knowledge base containing information from a URL
agno_docs = Knowledge(
# Use LanceDB as the vector database and store embeddings in the `agno_docs` table
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="agno_docs",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
agno_docs.insert(
url="https://docs.agno.com/llms-full.txt"
)
knowledge_tools = KnowledgeTools(
knowledge=agno_docs,
enable_think=True,
enable_search=True,
enable_analyze=True,
add_few_shot=True,
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[knowledge_tools],
markdown=True,
)
if __name__ == "__main__":
agent.print_response("How do I build multi-agent teams with Agno?", stream=True)The toolkit comes with default instructions and optional few-shot examples to help the Agent use the tools effectively. Here is how you can configure them:
from agno.tools.knowledge import KnowledgeTools
knowledge_tools = KnowledgeTools(
knowledge=agno_docs,
enable_think=True, # Enable the think tool (true by default)
enable_search=True, # Enable the search tool (true by default)
enable_analyze=True, # Enable the analyze tool (true by default)
add_instructions=True, # Add default instructions
add_few_shot=True, # Add few-shot examples (false by default)
few_shot_examples=None, # Optional custom few-shot examples
)