1
Create a Python file
change_state_on_run.py
2
Set up your virtual environment
3
Install dependencies
4
Export your OpenAI API key
5
Run Team
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Pass session_state per run to set and persist separate state for different users and sessions.
Create a Python file
from agno.db.in_memory import InMemoryDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
team = Team(
db=InMemoryDb(),
model=OpenAIResponses(id="gpt-5.2"),
members=[],
instructions="Users name is {user_name} and age is {age}",
)
# Sets the session state for the session with the id "user_1_session_1"
team.print_response(
"What is my name?",
session_id="user_1_session_1",
user_id="user_1",
session_state={"user_name": "John", "age": 30},
)
# Will load the session state from the session with the id "user_1_session_1"
team.print_response("How old am I?", session_id="user_1_session_1", user_id="user_1")
# Sets the session state for the session with the id "user_2_session_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},
)
# Will load the session state from the session with the id "user_2_session_1"
team.print_response("How old am I?", session_id="user_2_session_1", user_id="user_2")
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno openai
Export your OpenAI API key
OPENAI_API_KEY as an environment variable. You can get one from OpenAI.export OPENAI_API_KEY=sk-***
setx OPENAI_API_KEY sk-***
Run Team
python change_state_on_run.py
Was this page helpful?