Skip to main content
Team Session State enables sharing and updating state data across teams of agents. Teams often need to coordinate on shared information.
Shared state propagates through nested team structures as well

How to use Shared State

You can set the session_state parameter on Team to set initial session state data. This state data will be shared between the team leader and its members. This state will be available to all team members and is synchronized between them. For example:
Members can access the shared state using run_context.session_state in tools. For example:
The run_context object is automatically passed to the tool as an argument. Use it to access the session state. Any updates to run_context.session_state will be automatically persisted in the database and reflected in the shared state. See the RunContext schema for more information.

Example

Here’s a simple example of a team managing a shared shopping list:
team_session_state.py
Notice how shared tools can access and update run_context.session_state. This allows state data to propagate and persist across the entire team — even for subteams within the team.
See a full example here.

Agentic Session State

Agno provides a way to allow the team and team members to automatically update the shared session state. Simply set the enable_agentic_state parameter to True.
agentic_session_state.py
Don’t forget to set add_session_state_to_context=True to make the session state available to the team’s context.

Using state in instructions

You can reference variables from the session state in your instructions.
Don’t use the f-string syntax in the instructions. Directly use the {key} syntax, Agno substitutes the values for you.
state_in_instructions.py

Changing state on run

When you pass session_id to the team on team.run(), it will switch to the session with the given session_id and load any state that was set on that session. This is useful when you want to continue a session for a specific user.
changing_state_on_run.py

Overwriting the state in the db

By default, if you pass session_state to the run methods, this new state will be merged with the session_state in the db. You can change that behavior if you want to overwrite the session_state in the db:
overwriting_session_state_in_db.py

Team Member Interactions

Agent Teams can share interactions between members, allowing agents to learn from each other’s outputs:

Developer Resources