Skip to main content
When you add a database to your agent, sessions are stored automatically. A session groups related runs into a conversation thread - every message, response, and piece of metadata is persisted under a session_id. This page covers how to access and configure that storage.

Configure the Session Table

By default, sessions are stored in the agno_sessions table. The table is created automatically if it doesn’t exist. Use session_table to store sessions in a custom table:
from agno.db.postgres import PostgresDb

db = PostgresDb(
    db_url="postgresql://user:password@localhost:5432/mydb",
    session_table="my_agent_sessions",
)

agent = Agent(db=db)
Use separate tables for different agents or environments.

What Gets Stored

Each session record contains:
FieldTypeDescription
session_idstrUnique session identifier
session_typestrType of session (agent, team, or workflow)
agent_idstrThe agent ID (if agent session)
team_idstrThe team ID (if team session)
workflow_idstrThe workflow ID (if workflow session)
user_idstrThe user this session belongs to
session_datadictSession-specific data and state
agent_datadictAgent configuration and metadata
team_datadictTeam configuration and metadata
workflow_datadictWorkflow configuration and metadata
metadatadictAdditional custom metadata
runslistAll the runs (interactions) in this session
summarydictThe session summary (if enabled)
created_atintUnix timestamp when session was created
updated_atintUnix timestamp of last update

Retrieve Sessions

Use get_session() to retrieve a stored session:
from agno.agent import Agent
from agno.db.sqlite import SqliteDb

agent = Agent(db=SqliteDb(db_file="agent.db"))

agent.print_response("What is the capital of France?", session_id="session_123")

# Retrieve the session
session = agent.get_session(session_id="session_123")

# Access session data
print(session.session_id)
print(session.runs)  # List of runs with messages and responses

Works With Teams and Workflows

Session storage works identically for Teams and Workflows:
from agno.team import Team
from agno.workflow import Workflow
from agno.db.sqlite import SqliteDb

db = SqliteDb(db_file="agno.db")

team = Team(db=db, ...)
workflow = Workflow(db=db, ...)

# Retrieve sessions the same way
team_session = team.get_session(session_id="team_session_123")
workflow_session = workflow.get_session(session_id="workflow_session_456")
Workflow sessions store complete pipeline runs rather than conversation messages. See Workflow Sessions for details.

Next Steps

Developer Resources