Why do we need Session Storage? Agents are ephemeral and stateless. When you run an Agent, no state is persisted automatically. In production environments, we serve (or trigger) Agents via an API and need to continue the same session across multiple requests. Storage persists the session history and state in a database and allows 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. It lets us look at the data which helps us build better Agents. Adding storage to an Agent, Team or Workflow is as simple as providing a 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:
storage.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.db.sqlite import SqliteDb
from rich.pretty import pprint

agent = Agent(
     model=OpenAIChat(id="gpt-5-mini"),
    # Fix the session id to continue the same session across execution cycles
    session_id="fixed_id_for_demo",
    db=SqliteDb(db_file="tmp/data.db"),
    add_history_to_context=True,
    num_history_runs=3,
)
agent.print_response("What was my last question?")
agent.print_response("What is the capital of France?")
agent.print_response("What was my last question?")
pprint(agent.get_messages_for_session())
The first time you run this, the answer to “What was my last question?” will not be available. But run it again and the Agent will able to answer properly. Because we have fixed the session id, the Agent will continue from the same session every time you run the script.

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 session 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 session state between runs: save the Agent’s state to a database or file so you can inspect it later.
But there is so much more:
  • Storage saves our Agent’s session data for inspection and evaluations, including session metrics.
  • 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.
Storage is such a critical part of your Agentic infrastructure that it should never be offloaded to a third party. You should almost always use your own storage layer for your Agents.

Example: Use Postgres for storage

1

Run Postgres

Install docker desktop and run Postgres on port 5532 using:
docker run -d \
  -e POSTGRES_DB=ai \
  -e POSTGRES_USER=ai \
  -e POSTGRES_PASSWORD=ai \
  -e PGDATA=/var/lib/postgresql/data/pgdata \
  -v pgvolume:/var/lib/postgresql/data \
  -p 5532:5432 \
  --name pgvector \
  agno/pgvector:16
2

Create an Agent with Session Storage

Create a file agent_with_db.py with the following contents
from agno.agent import Agent
from agno.db.postgres import PostgresDb

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
db = PostgresDb(db_url=db_url)

session_id = "test-session"
user = "john@gmail.com"

agent = Agent(
    session_id=session_id,
    user_id=user,
    db=db,
    add_history_to_context=True,
    # Alternatively, enable the agent to read the chat history using a tool
    # read_chat_history=True,
)

agent.cli_app(markdown=True)
3

Run the agent

Install libraries
pip install -U agno openai pgvector pypdf psycopg sqlalchemy
Run the agent
python agent_with_db.py
Now tell the agent anything, and refer to previous messages in the conversation to see the benefits of storage:
Hi, my name is John!
Then message bye to exit, start the app again and ask:
What did I tell you last time?
4

Start a new run

Run the agent_with_db.py file.
python agent_with_db.py 

Session table schema

If you have a 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:
FieldTypeDescription
session_idstrThe unique identifier for the session.
session_typestrThe type of the session.
agent_idstrThe agent ID of the session.
team_idstrThe team ID of the session.
workflow_idstrThe workflow ID of the session.
user_idstrThe user ID of the session.
session_datadictThe data of the session.
agent_datadictThe data of the agent.
team_datadictThe data of the team.
workflow_datadictThe data of the workflow.
metadatadictThe metadata of the session.
runslistThe runs of the session.
summarydictThe summary of the session.
created_atintThe timestamp when the session was created.
updated_atintThe timestamp when the session was last updated.
This data is best displayed on the sessions page of the AgentOS UI.

Developer Resources