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

# State Management

> Persist and share data across agent runs, team coordination, and workflow execution

**State** is data that persists across multiple runs within a session, enabling agents, teams, and workflows to maintain context and remember information.

Common use cases include managing user-specific data like shopping lists, todo lists, preferences, or any information that needs to persist across interactions. State is managed through `session_state`, which can be accessed and updated in tools, then automatically persisted to your database.

## How State Works

State in Agno follows this pattern:

1. **Initialize** - Set default `session_state` when creating agents, teams, or workflows
2. **Access** - Tools access state via `run_context.session_state`
3. **Update** - Modifications are automatically persisted to the database
4. **Load** - Subsequent runs in the same session retrieve the stored state

### Basic Example

Here's a simple agent that maintains a shopping list:

```python theme={null}
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.run import RunContext

def add_item(run_context: RunContext, item: str) -> str:
    """Add an item to the shopping list."""
    run_context.session_state["shopping_list"].append(item)
    return f"Added {item}"

agent = Agent(
    db=SqliteDb(db_file="tmp/state.db"),
    session_state={"shopping_list": []},  # Default state
    tools=[add_item],
    instructions="Shopping list: {shopping_list}",  # State in instructions
)

agent.print_response("Add milk and eggs")
print(agent.get_session_state())  # {'shopping_list': ['milk', 'eggs']}
```

## Learn more

> **[Agent State](https://agno-v2.mintlify.site/state/agent/overview.md)**
>
> Store and update session state on a single agent.

> **[Team State](https://agno-v2.mintlify.site/state/team/overview.md)**
>
> Share state across a team and its members.

> **[Workflow State](https://agno-v2.mintlify.site/state/workflows/overview.md)**
>
> Pass state between workflow steps via run\_context.

## Developer Resources

* [Agent schema](https://agno-v2.mintlify.site/reference/agents/agent.md)
* [Team schema](https://agno-v2.mintlify.site/reference/teams/team.md)
* [Workflow schema](https://agno-v2.mintlify.site/reference/workflows/workflow.md)
* [RunContext schema](https://agno-v2.mintlify.site/reference/run/run-context.md)


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