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

# Agent Storage

> Persist agent sessions, memory, knowledge, traces, approvals, schedules, evaluations, and metrics.

Agent state has to remain available across conversations, restarts, and replicas. Agents, teams, workflows, and AgentOS share a `db` interface for sessions, memory, learnings, knowledge metadata, traces, schedules, approvals, evaluations, and metrics.

The `db` parameter accepts JSON file, embedded, relational, document, key-value, and distributed backends.

```python theme={null}
from agno.db.postgres import PostgresDb
from agno.os import AgentOS

db = PostgresDb(db_url="postgresql+psycopg://user:pass@host:5432/agno")

agent_os = AgentOS(agents=[agent], db=db)
```

AgentOS creates the tables and indexes on first boot. Set `auto_provision_dbs=False` on `AgentOS` when you manage the schema yourself.

## What gets stored

| Table | Holds |
| - | - |
| `agno_sessions` | Conversation history per `(user_id, session_id)` |
| `agno_memories` | User memories the agent decides to keep |
| `agno_learnings` | Learnings captured from runs |
| `agno_knowledge` | Knowledge content metadata (embeddings live in the vector store) |
| `agno_traces`, `agno_spans` | OpenTelemetry traces |
| `agno_approvals` | Pending and resolved HITL requests |
| `agno_schedules`, `agno_schedule_runs` | Cron jobs |
| `agno_metrics`, `agno_eval_runs` | Metrics and eval results |

Backend-specific table and collection names may vary.

## Pick a backend

Most tutorials use `PostgresDb`. Pair it with `PgVector` when you want relational data and embeddings on the same Postgres instance.

| Backend | When to use |
| - | - |
| [`PostgresDb`](https://agno-v2.mintlify.site/database/providers/postgres/overview) | Production runtime state; pair with `PgVector` for embeddings |
| [`SqliteDb`](https://agno-v2.mintlify.site/database/providers/sqlite/overview) | Local dev, single-user demos, edge deployments |
| [`MongoDb`](https://agno-v2.mintlify.site/database/providers/mongo/overview) | Already on Mongo |
| [`MySQLDb`](https://agno-v2.mintlify.site/database/providers/mysql/overview) | Already on MySQL |
| [`SingleStoreDb`](https://agno-v2.mintlify.site/database/providers/singlestore/overview) | Existing SingleStore infrastructure and high-throughput runtime state |
| [`RedisDb`](https://agno-v2.mintlify.site/database/providers/redis/overview) | Existing Redis infrastructure and high-throughput key-value access |
| [`ValkeyDb`](https://agno-v2.mintlify.site/database/providers/valkey/overview) | Existing Valkey infrastructure and high-throughput key-value access |
| [`DynamoDb`](https://agno-v2.mintlify.site/database/providers/dynamodb/overview) | AWS-native, serverless |
| [`FirestoreDb`](https://agno-v2.mintlify.site/database/providers/firestore/overview) | GCP-native, serverless |
| [`JsonDb`](https://agno-v2.mintlify.site/database/providers/json/overview) | Local JSON file storage |
| [`GcsJsonDb`](https://agno-v2.mintlify.site/database/providers/gcs/overview) | JSON-backed records in Google Cloud Storage |
| [`InMemoryDb`](https://agno-v2.mintlify.site/database/providers/in-memory/overview) | Tests, ephemeral demos |

Postgres-compatible managed services like [Neon](https://agno-v2.mintlify.site/database/providers/neon/overview.md) and [Supabase](https://agno-v2.mintlify.site/database/providers/supabase/overview.md) work with `PostgresDb` directly. Point `db_url` at the managed instance. Async variants (`AsyncPostgresDb`, `AsyncSqliteDb`, `AsyncMongoDb`, `AsyncMySQLDb`) are documented under [Database](https://agno-v2.mintlify.site/database/overview.md).

## Vector storage

Knowledge uses a vector store for embedding search.

```python theme={null}
from agno.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector
from agno.vectordb.search import SearchType

agent = Agent(
    db=db,
    knowledge=Knowledge(
        vector_db=PgVector(
            table_name="my_kb",
            db_url=DB_URL,
            search_type=SearchType.hybrid,   # vector + full-text search
        ),
    ),
)
```

Other options: LanceDB, Qdrant, Weaviate, Pinecone, Chroma, MongoDB Atlas, Cosmos, Cassandra, ClickHouse, SurrealDB, Milvus. See [Vector Stores](https://agno-v2.mintlify.site/knowledge/vector-stores/index.md).

For production deployments already using Postgres, pair `PostgresDb` with `PgVector` to keep runtime state and hybrid search in one Postgres service.

## Splitting concerns across databases

Every agent, team, and workflow can take its own `db`, overriding the AgentOS default.

Use the AgentOS `db` for shared state and hand individual components a separate database when they need isolation:

```python theme={null}
shared_db = PostgresDb(db_url="postgresql+psycopg://shared/...")
tenant_db = PostgresDb(db_url="postgresql+psycopg://tenant-a/...")

tenant_agent = Agent(name="tenant-a-support", db=tenant_db)
internal_agent = Agent(name="ops", db=shared_db)

agent_os = AgentOS(
    agents=[tenant_agent, internal_agent],
    db=shared_db,
)
```

Common splits include separate tenant databases, a high-traffic agent on its own engine, or one workflow's session history on a different backend. Database-level tenant isolation also requires separate credentials and grants.

## File and blob storage

Store generated images, audio, and large PDFs in object storage, then reference their paths in `agno_knowledge` or `agno_sessions`.

## Developer Resources

* [Database overview](https://agno-v2.mintlify.site/database/overview.md)
* [Vector stores](https://agno-v2.mintlify.site/knowledge/vector-stores/index.md)
* [Database migrations](https://agno-v2.mintlify.site/agent-os/usage/database-migrations.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.