This example demonstrates how to enable agentic session state management, allowing the agent to automatically update and manage session state based on conversation context. The agent can modify the shopping list based on user interactions.
from agno.agent import Agentfrom agno.db.sqlite import SqliteDbfrom agno.models.openai import OpenAIChatdb = SqliteDb(db_file="tmp/agents.db")agent = Agent( model=OpenAIChat(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,)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()}")