1
Create a Python file
agentic_session_state.py
2
Set up your virtual environment
3
Install dependencies
4
Export your OpenAI API key
5
Run Agent
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Create a Python file
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
db = SqliteDb(db_file="tmp/agents.db")
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=db,
session_state={"shopping_list": []},
add_session_state_to_context=True,
enable_agentic_state=True,
)
agent.print_response("Add milk, eggs, and bread to the shopping list", stream=True)
agent.print_response("I picked up the eggs, now what's on my list?", stream=True)
print(f"Session state: {agent.get_session_state()}")
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno openai
Export your OpenAI API key
OPENAI_API_KEY as an environment variable. You can get one from OpenAI.export OPENAI_API_KEY=sk-***
setx OPENAI_API_KEY sk-***
Run Agent
python agentic_session_state.py
Was this page helpful?