Agent with Knowledge Tools
Give an agent KnowledgeTools backed by a LanceDB hybrid-search knowledge base to think, search, and analyze before answering.
Add the following code to your Python file
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 containing information from a URL
agno_docs = Knowledge(
# Use LanceDB as the vector database and store embeddings in the `sdk_reasoning_agno_docs` table
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="sdk_reasoning_agno_docs",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
# Add content to the knowledge
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 a team of agents in agno?",
markdown=True,
stream=True,
)Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai lancedb beautifulsoup4Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run Agent
python knowledge_tools.py