Knowledge Agents

Build agents that answer from indexed content with controlled ingestion, retrieval, filtering, and source updates.

Engineering and operations teams use knowledge agents to answer questions from product documentation, policies, and internal procedures. Agno provides ingestion, retrieval, metadata filtering, corpus isolation, and source updates. AgentOS exposes the knowledge base through its API and Control Plane.

knowledge_agent.py
from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.chroma import ChromaDb
from agno.vectordb.search import SearchType

knowledge = Knowledge(
    name="Company handbook",
    vector_db=ChromaDb(
        collection="company_handbook",
        path="tmp/chromadb",
        persistent_client=True,
        search_type=SearchType.hybrid,
        embedder=OpenAIEmbedder(id="text-embedding-3-small"),
    ),
)

knowledge.insert(
    name="Travel policy",
    text_content=(
        "Domestic travel under $2,000 requires manager approval. "
        "International travel and travel costing $2,000 or more require VP approval."
    ),
    skip_if_exists=True,
)

agent = Agent(
    name="Policy Agent",
    model="openai:gpt-5.5",
    knowledge=knowledge,
    search_knowledge=True,
    instructions=[
        "Use the knowledge base for policy questions.",
        "Say when the answer is not in the knowledge base.",
    ],
)

agent.print_response("When does travel need VP approval?", stream=True)

Create a virtual environment, install the OpenAI and ChromaDB integrations, and set OPENAI_API_KEY before running the agent:

uv venv --python 3.12
uv pip install -U "agno[chromadb,openai]"
export OPENAI_API_KEY="your_openai_api_key"
uv run python knowledge_agent.py

The agent decides when to search the indexed policy. ChromaDB persists the embedded content under tmp/chromadb for later runs.

Choose the information path

InformationPattern
Policies, manuals, and product documentationIndex the corpus with Knowledge.
Current account, order, or operational dataQuery a context provider, tool, or MCP server at run time.
Policies plus current recordsRetrieve the rules from Knowledge, then call a tool for the current record.
Typed fields extracted from incoming filesUse Document Processing.

Knowledge owns indexed content and retrieval. Context providers and tools query live systems. Customer-facing agents add sessions, authentication, and interfaces around either pattern.

Choose retrieval behavior

BehaviorConfigurationUse when
Agentic searchsearch_knowledge=TrueThe agent may need several searches or no search.
Automatic contextadd_knowledge_to_context=True, search_knowledge=FalseEach string input should receive retrieved context before the model runs.
Custom retrievalSet a custom knowledge_retrieverAn existing search service owns query rewriting, ranking, or access checks.

Start with agentic search. Add automatic context when each string input depends on the corpus. Use a custom retriever when retrieval policy lives outside Agno.

Protect corpus boundaries

RequirementControl
Several named corpora share one vector databaseGive each Knowledge instance a unique name and set isolate_vector_search=True.
Results should match document attributesInsert metadata and apply knowledge filters.
Tenant or user authorizationAuthenticate and authorize the caller before retrieval. Apply metadata filters from the verified identity to narrow results.
Users can submit remote URLsConfigure reader allowed_hosts and follow the SSRF hardening pattern.

Reindex older content before enabling isolated vector search if its vectors do not contain linked_to metadata.

Production path

NeedGuide
Ingest files, URLs, and textKnowledge quickstart
Track content state and updatesContents database and knowledge lifecycle example
Choose a production vector databaseVector stores
Choose vector, keyword, or hybrid retrievalSearch and retrieval
Tune how documents are splitChunking
Isolate customer corporaMulti-tenant example
Manage content through AgentOSManage knowledge
Catch retrieval or answer regressionsAgent Evaluation

Next steps

TaskGuide
Build your first indexed agentKnowledge quickstart
Combine several source typesMulti-source RAG
Share retrieval across specialistsKnowledge for teams
Query live systems instead of an indexConnecting your data