> ## 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.

# Overwrite Stored Session State

> Demonstrates replacing persisted session_state with run-time session_state.

```python overwrite_stored_session_state.py theme={null}
"""
Overwrite Stored Session State
==============================

Demonstrates replacing persisted session_state with run-time session_state.
"""

from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.team import Team

# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
team = Team(
    model=OpenAIResponses(id="gpt-5.2"),
    db=SqliteDb(db_file="tmp/agents.db"),
    members=[],
    markdown=True,
    session_state={},
    add_session_state_to_context=True,
    overwrite_db_session_state=True,
)

# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    team.print_response(
        "Can you tell me what's in your session_state?",
        session_state={"shopping_list": ["Potatoes"]},
        stream=True,
    )
    print(f"Stored session state: {team.get_session_state()}")

    team.print_response(
        "Can you tell me what is in your session_state?",
        session_state={"secret_number": 43},
        stream=True,
    )
    print(f"Stored session state: {team.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 `overwrite_stored_session_state.py`, then run:

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

Full source: [cookbook/03\_teams/21\_state/overwrite\_stored\_session\_state.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/03_teams/21_state/overwrite_stored_session_state.py)


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