Documentation Index
Fetch the complete documentation index at: https://spacesail.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
This example demonstrates how to enable automatic session summaries that help maintain conversation context across longer interactions by summarizing previous conversations.
Code
"""
This example shows how to use the session summary to store the conversation summary.
"""
from agno.agent.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIChat
from agno.session.summary import SessionSummaryManager # noqa: F401
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
db = PostgresDb(db_url=db_url, session_table="sessions")
# Method 1: Set enable_session_summaries to True
agent = Agent(
model=OpenAIChat(id="gpt-5-mini"),
db=db,
enable_session_summaries=True,
session_id="session_summary",
)
agent.print_response("Hi my name is John and I live in New York")
agent.print_response("I like to play basketball and hike in the mountains")
# Method 2: Set session_summary_manager
# session_summary_manager = SessionSummaryManager(model=OpenAIChat(id="gpt-5-mini"))
# agent = Agent(
# model=OpenAIChat(id="gpt-5-mini"),
# db=db,
# session_id="session_summary",
# session_summary_manager=session_summary_manager,
# )
# agent.print_response("Hi my name is John and I live in New York")
# agent.print_response("I like to play basketball and hike in the mountains")
Usage
Create a virtual environment
Open the Terminal and create a python virtual environment.python3 -m venv .venv
source .venv/bin/activate
Install libraries
pip install -U agno openai psycopg2-binary
Setup PostgreSQL
# Make sure PostgreSQL is running
# Update connection string in the code as needed
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
Create a Python file
Create a Python file and add the above code.touch 03_session_summary.py
Run Agent
python 03_session_summary.py
Find All Cookbooks
Explore all the available cookbooks in the Agno repository. Click the link below to view the code on GitHub:Agno Cookbooks on GitHub