Skip to main content
Agents use storage to persist sessions by storing them in a database. Agents come with built-in memory, but it only lasts while the session is active. To continue conversations across sessions, we store agent sessions in a database like PostgreSQL. The general syntax for adding storage to an Agent looks like:

Example

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 contents
3

Run the agent

Install libraries
Run the agent
Now 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.

Params