> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-service-account.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic State

Enable agentic session state so the agent updates session state on its own based on the conversation. Here the agent manages a shopping list as the user talks to it.

<Steps>
  <Step title="Create a Python file">
    ```python agentic_session_state.py theme={null}
    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()}")
    ```
  </Step>

  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai sqlalchemy
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <Snippet file="set-openai-key.mdx" />
  </Step>

  <Step title="Run Agent">
    ```bash theme={null}
    python agentic_session_state.py
    ```
  </Step>
</Steps>
