Storage driver and Agno handles the rest. You can use Sqlite, Postgres, Mongo or any other database you want.
Here’s a simple example that demostrates persistence across execution cycles:
storage.py
Benefits of Storage
Storage has typically been an under-discussed part of Agent Engineering — but we see it as the unsung hero of production agentic applications. In production, you need storage to:- Continue sessions: retrieve sessions history and pick up where you left off.
- Get list of sessions: To continue a previous session, you need to maintain a list of sessions available for that agent.
- Save state between runs: save the Agent’s state to a database or file so you can inspect it later.
- Storage saves our Agent’s session data for inspection and evaluations.
- Storage helps us extract few-shot examples, which can be used to improve the Agent.
- Storage enables us to build internal monitoring tools and dashboards.
Example: Use Postgres for storage
1
Run Postgres
Install docker desktop and run Postgres on port 5532 using:
2
Create an Agent with Storage
Create a file
agent_with_storage.py with the following contents3
Run the agent
Install librariesRun the agentNow the agent continues across sessions. Ask a question:Then message
bye to exit, start the app again and ask:4
Start a new run
Run the
agent_with_storage.py file with the --new flag to start a new run.Schema Upgrades
When usingAgentStorage, the SQL-based storage classes have fixed schemas. As new Agno features are released, the schemas might need to be updated.
Upgrades can either be done manually or automatically.
Automatic Upgrades
Automatic upgrades are done when theauto_upgrade_schema parameter is set to True in the storage class constructor.
You only need to set this once for an agent run and the schema would be upgraded.
Manual Upgrades
Manual schema upgrades can be done by calling theupgrade_schema method on the storage class.
Params
Developer Resources
- View Cookbook