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

# Change State On Run

> Demonstrates per-run session state overrides for different users/sessions.

```python change_state_on_run.py theme={null}
"""
Change State On Run
===================

Demonstrates per-run session state overrides for different users/sessions.
"""

from agno.db.in_memory import InMemoryDb
from agno.models.openai import OpenAIResponses
from agno.team import Team

# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
team = Team(
    db=InMemoryDb(),
    model=OpenAIResponses(id="gpt-5.2"),
    members=[],
    instructions="Users name is {user_name} and age is {age}",
)

# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    team.print_response(
        "What is my name?",
        session_id="user_1_session_1",
        user_id="user_1",
        session_state={"user_name": "John", "age": 30},
    )

    team.print_response(
        "How old am I?",
        session_id="user_1_session_1",
        user_id="user_1",
    )

    team.print_response(
        "What is my name?",
        session_id="user_2_session_1",
        user_id="user_2",
        session_state={"user_name": "Jane", "age": 25},
    )

    team.print_response(
        "How old am I?",
        session_id="user_2_session_1",
        user_id="user_2",
    )
```

## Run the Example

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

**1. Install dependencies**

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

**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 `change_state_on_run.py`, then run:

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

Full source: [cookbook/03\_teams/21\_state/change\_state\_on\_run.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/03_teams/21_state/change_state_on_run.py)


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