AIAgentStorage

Concurrent-safe key-value storage for an agent. You can create typed keys for your data using the createStorageKey function and set and retrieve data using it by calling set and get.

Functions

Link copied to clipboard
suspend fun clear()

Clears all data from the storage.

Link copied to clipboard
suspend fun <T : Any> get(key: AIAgentStorageKey<T>): T?

Retrieves the value associated with the given key from the storage.

Link copied to clipboard
suspend fun putAll(map: Map<AIAgentStorageKey<*>, Any>)

Adds all key-value pairs from the given map to the storage.

Link copied to clipboard
suspend fun <T : Any> remove(key: AIAgentStorageKey<T>): T?

Removes the value associated with the given key from the storage.

Link copied to clipboard
suspend fun <T : Any> set(key: AIAgentStorageKey<T>, value: T)

Sets the value associated with the given key in the storage.

Link copied to clipboard
suspend fun toMap(): Map<AIAgentStorageKey<*>, Any>

Converts the storage to a map representation.