When should I use Storage on my Agents?Agents are ephemeral by default. They won’t remember previous conversations.But in production environments, you will often need to continue the same session across multiple requests. Storage is the way to persist the session history and state in a database, enabling us to pick up where we left off.Storage also lets us inspect and evaluate Agent sessions, extract few-shot examples and build internal monitoring tools. In general, it lets you keep track of the data, to build better Agents.
Adding storage to your Agent
To enable session persistence on your Agent, just setup a database and provide it to the Agent:It’s recommended to add
id
for better management and easier identification of database. You can add it to your database configuration like this:Adding session history to the context
Agents with adb
will persist their sessions in the database. You can also automatically add the persisted history to the context, effectively enabling Agents to persist sessions:
Where are sessions stored?
By default, sessions are stored in theagno_sessions
table of the database.
If the table or collection doesn’t exist, it is created automatically when first storing a session.
You can specify where the sessions are stored exactly using the session_table
parameter:
Retrieving sessions
You can manually retrieve stored sessions using theget_session
method. This also works for Teams
and Workflows
:
Benefits of using session storage
When building production-ready agentic applications, storage will often be a very important feature. This is because it enables to:- Continue a session: retrieve previous messages and enable users to pick up a conversation where they left off.
- Keep a record of sessions: enable users to inspect their past conversations.
- Data ownership: keeping sessions in your own database gives you full control over the data.
Storage is a critical part of your Agentic infrastructure. We recommend to
never offload it to a third-party service. You should almost always use your
own storage layer for your Agents.
Storage for Teams and Workflows
Storage also works with Teams and Workflows, providing persistent memory for your more complex agentic applications. Similarly to Agents, you simply need to provide your Team or Workflow with a database for sessions to be persisted:Supported databases
This is the list of the databases we currently support:DynamoDB
Amazon’s NoSQL database service
FireStore
Google’s NoSQL document database
JSON
Simple file-based JSON storage
JSON on GCS
JSON storage on Google Cloud Storage
MongoDB
Popular NoSQL document database
MySQL
Widely-used relational database
Neon
Serverless PostgreSQL platform
PostgreSQL
Advanced open-source relational database
Redis
In-memory data structure store
SingleStore
Real-time analytics database
SQLite
Lightweight embedded database
Supabase
Open source Firebase alternative
We also support using an In-Memory database. This is not recommended for production, but perfect for demos and testing.