Copy
Ask AI
"""
Agentic Session State
=============================
Agentic Session State.
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
db = SqliteDb(db_file="tmp/agents.db")
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=OpenAIResponses(id="gpt-5-mini"),
db=db,
session_state={"shopping_list": []},
add_session_state_to_context=True, # Required so the agent is aware of the session state
enable_agentic_state=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent.print_response("Add milk, eggs, and bread to the shopping list")
agent.print_response("I picked up the eggs, now what's on my list?")
print(f"Session state: {agent.get_session_state()}")
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/02_agents/05_state_and_session
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python agentic_session_state.py