Skip to main content
State lets your agent persist data between handler calls. The ADK provides three scopes depending on how long you need the data and who should have access to it.

State scopes

Defining state schemas

Bot and user state

Define bot and user state in agent.config.ts:
Use .default() to set initial values and .describe() to document what each field is for.

Conversation state

Define conversation state on a Conversation using the state prop:

Reading and writing state

State objects are mutable and can be modified directly. Your changes are saved automatically—you don’t need to call a save method.

Bot state

You can access bot state anywhere in your agent (conversations, actions, tools, workflows):

User state

You can access user state anywhere the current user context exists:

Conversation state

You can access conversation state via the state parameter in the conversation handler:

Loading by ID

You can load any user or conversation by ID to read and write their state and tags from anywhere in your agent:
Changes to loaded instances are auto-saved, just like the current user and conversation.

State references

You can store workflow instances in state. They are saved automatically and loaded back as full instances when read:

Tags

Tags are string key-value pairs you can attach to bots, users, conversations, messages, and workflows. They’re useful for categorization, filtering, and querying.

Defining tags

Declare tags in agent.config.ts:

Reading and writing tags

You can access conversation tags via the conversation instance:
System tags set by integrations (keys containing :) are read-only:

Bot and user identity

The bot and user objects also expose an id property:
Last modified on April 27, 2026