Use Storage to persist Agent sessions and state to a database or file.
DB
driver and Agno handles the rest. You can use Sqlite, Postgres, Mongo or any other database you want.
Here’s a simple example that demonstrates persistence across execution cycles:
Run Postgres
Create an Agent with Session Storage
agent_with_db.py
with the following contentsRun the agent
bye
to exit, start the app again and ask:Start a new run
agent_with_db.py
file.db
configured for your agent, the sessions will be stored in the a sessions table in your database.
The schema for the sessions table is as follows:
Field | Type | Description |
---|---|---|
session_id | str | The unique identifier for the session. |
session_type | str | The type of the session. |
agent_id | str | The agent ID of the session. |
team_id | str | The team ID of the session. |
workflow_id | str | The workflow ID of the session. |
user_id | str | The user ID of the session. |
session_data | dict | The data of the session. |
agent_data | dict | The data of the agent. |
team_data | dict | The data of the team. |
workflow_data | dict | The data of the workflow. |
metadata | dict | The metadata of the session. |
runs | list | The runs of the session. |
summary | dict | The summary of the session. |
created_at | int | The timestamp when the session was created. |
updated_at | int | The timestamp when the session was last updated. |