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

# Agentic Session State

> Let the agent update its own session_state shopping list with enable_agentic_state.

Agentic Session State.

```python agentic_session_state.py theme={null}
"""
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

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai sqlalchemy
```

**2. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Run the example**

Save the code above as `agentic_session_state.py`, then run:

```bash theme={null}
python agentic_session_state.py
```

Full source: [cookbook/02\_agents/05\_state\_and\_session/agentic\_session\_state.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/02_agents/05_state_and_session/agentic_session_state.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.