AIAgentContext

The AIAgentContext interface represents the context of an AI agent in the lifecycle. It provides access to the environment, configuration, LLM context, state management, storage, and other metadata necessary for the operation of the agent. Additionally, it supports features for custom workflows and extensibility.

Inheritors

Properties

Link copied to clipboard
abstract val agent: AIAgent<*, *>

Represents the AIAgent holding the current AIAgentContext.

Link copied to clipboard
open val agentId: String

A unique identifier representing the current agent instance within the context. The value is derived from the underlying agent.id.

Link copied to clipboard
abstract val agentInput: Any?

Represents the input provided to the agent's execution.

Link copied to clipboard
abstract val config: AIAgentConfig

Represents the configuration for an AI agent.

Link copied to clipboard

Represents the environment in which the agent operates.

Link copied to clipboard
abstract val llm: AIAgentLLMContext

Represents the AI agent's LLM context, providing mechanisms for managing tools, prompts, and interaction with the execution environment. It ensures thread safety during concurrent read and write operations through the use of sessions.

Link copied to clipboard

Represents the parent context of the AI Agent.

Link copied to clipboard
abstract val runId: String

A unique identifier for the current session associated with the AI agent context. Used to track and differentiate sessions within the execution of the agent pipeline.

Link copied to clipboard

Manages and tracks the state of aт AI agent within the context of its execution.

Link copied to clipboard
abstract val storage: AIAgentStorage

Concurrent-safe key-value storage for an agent, used to manage and persist data within the context of a the AI agent stage execution. The storage property provides a thread-safe mechanism for sharing and storing data specific to the agent's operation.

Link copied to clipboard
abstract val strategyName: String

Represents the name of the strategy being used in the current AI agent context.

Functions

Link copied to clipboard
inline fun <T> AIAgentContext.agentInput(): T

Utility function to get AIAgentContext.agentInput and try to cast it to some expected type.

Link copied to clipboard

Retrieves a feature from the current context using the specified key.

abstract fun <Feature : Any> feature(feature: AIAgentFeature<*, Feature>): Feature?

Retrieves a feature of the specified type from the current context.

Link copied to clipboard

Retrieves a feature of the specified type from the context or throws an exception if it is not available.

Link copied to clipboard
abstract fun <T> get(key: AIAgentStorageKey<*>): T?

Retrieves data from the agent's storage using the specified key.

Link copied to clipboard

Retrieves the agent-specific context data associated with the current instance.

Link copied to clipboard
abstract suspend fun getHistory(): List<Message>

Retrieves the history of messages exchanged during the agent's execution.

Link copied to clipboard
abstract fun remove(key: AIAgentStorageKey<*>): Boolean

Removes a feature or data associated with the specified key from the agent's storage.

Link copied to clipboard

Removes the agent-specific context data associated with the current context.

Link copied to clipboard

Provides the root context of the current agent. If the root context is not defined, this function defaults to returning the current instance.

Link copied to clipboard
abstract fun store(key: AIAgentStorageKey<*>, value: Any)

Stores a feature in the agent's storage using the specified key.

Link copied to clipboard

Stores the given agent context data within the current AI agent context.