AIAgentStateManager

class AIAgentStateManager(state: AIAgentState = AIAgentState())(source)

Manages the state of an AI agent by providing thread-safe access and mechanisms to update the internal state using a locking mechanism.

This class ensures consistency across state modifications by using a mutual exclusion lock, allowing only one coroutine to access or modify the state at a time.

Constructors

Link copied to clipboard
constructor(state: AIAgentState = AIAgentState())

Creates a new instance of AIAgentStateManager with the initial state, defaulting to a new AIAgentState if not provided.

Functions

Link copied to clipboard
suspend fun <T> withStateLock(block: suspend (AIAgentState) -> T): T

Executes the provided suspending block of code with exclusive access to the current state.