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:latest

Set 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

ParameterTypeDefaultDescription
knowledgeKnowledge-Knowledge base instance (required).
enable_thinkboolTrueEnable reasoning capabilities.
enable_searchboolTrueEnable knowledge search functionality.
enable_analyzeboolTrueEnable knowledge analysis capabilities.
instructionsOptional[str]NoneCustom instructions for knowledge operations.
add_instructionsboolTrueWhether to add instructions to the agent.
add_few_shotboolFalseWhether to include few-shot examples.
few_shot_examplesOptional[str]NoneCustom few-shot examples.
allboolFalseEnable all functionality.

Toolkit Functions

FunctionDescription
thinkScratchpad for reasoning about the question and planning searches.
search_knowledgeSearch the knowledge base for relevant information.
analyzeRecord 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.

Developer Resources