Creates a new instance of AgentState.
The storage provider used to persist state between turns
A factory function that generates keys for storing state data
ProtectedstorageThe storage provider used to persist state between turns
ProtectedstorageA factory function that generates keys for storing state data
Clears the state by setting it to an empty object in the turn context.
The turn context containing the state to clear
A promise that resolves when the clear operation is complete
Creates a property accessor for the specified property.
The name of the property to access
A property accessor for the specified property
Deletes the state from both the turn context and storage.
The turn context containing the state to delete
OptionalcustomKey: CustomKeyOptional custom storage key to use instead of the default
A promise that resolves when the delete operation is complete
Gets the state from the turn context without loading it from storage.
The turn context containing the state to get
The state object, or undefined if no state is found in the turn context
Loads the state from storage into the turn context.
The turn context to load state into
If true, forces a reload from storage even if state is cached
OptionalcustomKey: CustomKeyOptional custom storage key to use instead of the default
A promise that resolves to the loaded state object
Saves the state to storage if it has changed since it was loaded.
The turn context containing the state to save
If true, forces a save to storage even if no changes are detected
OptionalcustomKey: CustomKeyOptional custom storage key to use instead of the default
A promise that resolves when the save operation is complete
Manages the state of an Agent across turns in a conversation.
Remarks
AgentState provides functionality to persist and retrieve state data using a storage provider. It handles caching state in the turn context for performance, calculating change hashes to detect modifications, and managing property accessors for typed access to state properties.