> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Knowledge

> Attach Knowledge to your AgentOS instance

The AgentOS control plane provides a simple way to [manage](/agent-os/features/knowledge-management#adding-content) your Knowledge bases.
You can add, edit, and delete content from your Knowledge bases directly through the control plane.

You can specify multiple Knowledge bases and reuse the same Knowledge instance
across different Agents or Teams as needed.

## Prerequisites

Before setting up Knowledge management in AgentOS, ensure you have:

* PostgreSQL database running and accessible - used for this example
* Required dependencies installed: `uv pip install agno`
* OpenAI API key configured (for embeddings)
* Basic understanding of [Knowledge concepts](/knowledge/quickstart)

## Example

This example demonstrates how to attach multiple Knowledge bases to AgentOS
and populate them with content from different sources.

```python agentos_knowledge.py theme={null}
from textwrap import dedent

from agno.db.postgres import PostgresDb
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.os import AgentOS
from agno.vectordb.pgvector import PgVector, SearchType

# ************* Setup Knowledge Databases *************
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
documents_db = PostgresDb(
    db_url,
    id="agno_knowledge_db",
    knowledge_table="agno_knowledge_contents",
)
faq_db = PostgresDb(
    db_url,
    id="agno_faq_db",
    knowledge_table="agno_faq_contents",
)
# *******************************

documents_knowledge = Knowledge(
    vector_db=PgVector(
        db_url=db_url,
        table_name="agno_knowledge_vectors",
        search_type=SearchType.hybrid,
        embedder=OpenAIEmbedder(id="text-embedding-3-small"),
    ),
    contents_db=documents_db,
)

faq_knowledge = Knowledge(
    vector_db=PgVector(
        db_url=db_url,
        table_name="agno_faq_vectors",
        search_type=SearchType.hybrid,
        embedder=OpenAIEmbedder(id="text-embedding-3-small"),
    ),
    contents_db=faq_db,
)

agent_os = AgentOS(
    description="Example app with AgentOS Knowledge",
    # Add the knowledge bases to AgentOS
    knowledge=[documents_knowledge, faq_knowledge],
)


app = agent_os.get_app()

if __name__ == "__main__":
    documents_knowledge.insert(
        name="Agno Docs", url="https://docs.agno.com/llms-full.txt", skip_if_exists=True
    )
    faq_knowledge.insert(
        name="Agno FAQ",
        text_content=dedent("""
            What is Agno?
            Agno is a framework for building agents.
            Use it to build multi-agent systems with memory, knowledge,
            human in the loop and MCP support.
        """),
        skip_if_exists=True,
    )
    # Run your AgentOS
    # You can test your AgentOS at: http://localhost:7777/

    agent_os.serve(app="agentos_knowledge:app")
```

### Screenshots

The screenshots below show how you can access and manage your different Knowledge bases through the AgentOS interface:

<img src="https://mintcdn.com/agno-v2/tBgqL1LeYUKpZTuS/images/agno_knowledge_db.png?fit=max&auto=format&n=tBgqL1LeYUKpZTuS&q=85&s=b7def1bd459cf44ad505591fedb7d93c" alt="llm-app-aidev-run" width="3410" height="750" data-path="images/agno_knowledge_db.png" />

<img src="https://mintcdn.com/agno-v2/tBgqL1LeYUKpZTuS/images/agno_faq_db.png?fit=max&auto=format&n=tBgqL1LeYUKpZTuS&q=85&s=e0b00d9eaa45fa729acfea31f4c999e3" alt="llm-app-aidev-run" width="3410" height="750" data-path="images/agno_faq_db.png" />

## Knowledge ID

Each Knowledge instance registered with AgentOS gets a deterministic `knowledge_id`. This ID is generated from the combination of the instance's `name`, database ID, and table name. The same inputs always produce the same ID, so it is stable across restarts.

Use `knowledge_id` in API calls to target a specific Knowledge instance:

```bash theme={null}
# List content sources
curl http://localhost:7777/v1/knowledge/{knowledge_id}/sources

# Browse files in an S3 source
curl "http://localhost:7777/v1/knowledge/{knowledge_id}/sources/{source_id}/files?prefix=reports/"

# Upload content
curl -X POST http://localhost:7777/v1/knowledge/{knowledge_id}/content \
  -F "file=@report.pdf" \
  -F "name=Q4 Report"
```

### Finding your Knowledge ID

The `/knowledge/config` endpoint returns all registered Knowledge instances with their IDs:

```bash theme={null}
curl http://localhost:7777/v1/knowledge/config | jq '.knowledge_instances'
```

```json theme={null}
[
  {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "documents_knowledge",
    "db_id": "agno_knowledge_db",
    "table": "agno_knowledge_contents"
  },
  {
    "id": "f9e8d7c6-b5a4-3210-fedc-ba0987654321",
    "name": "faq_knowledge",
    "db_id": "agno_faq_db",
    "table": "agno_faq_contents"
  }
]
```

### Backward compatibility

If you have a single Knowledge instance, you can omit `knowledge_id` from API calls. For multiple instances, you can also use the `db_id` query parameter, but `knowledge_id` is preferred as it uniquely identifies the instance even when multiple instances share the same database.

## Best Practices

* **Separate Knowledge by Domain**: Create separate Knowledge bases for different topics (e.g., technical docs, FAQs, policies)
* **Consistent Naming**: Use descriptive names for your Knowledge bases that reflect their content
* **Regular Updates**: Keep your Knowledge bases current by regularly adding new content and removing outdated information
* **Monitor Performance**: Use different table names for vector storage to avoid conflicts
* **Content Organization**: Use the `name` parameter when adding content to make it easily identifiable
* **Use metadata for filtering and searching**: Add metadata to your content to make it easier to find and filter

## Troubleshooting

<AccordionGroup>
  <Accordion title="Knowledge base not appearing in AgentOS interface">
    Ensure your knowledge base is properly added to the `knowledge` parameter when creating your AgentOS instance.
    Also make sure to attach a `contents_db` to your Knowledge instance.
  </Accordion>

  <Accordion title="Database connection errors">
    Verify your PostgreSQL connection string and ensure the database is running and accessible.
  </Accordion>

  <Accordion title="Content not being found in searches">
    Check that your content has been properly embedded by verifying entries in your vector database table.
  </Accordion>
</AccordionGroup>
