AIAgentParallelNodesMergeContext

Context for merging parallel node execution results.

This class provides DSL methods for selecting and folding results from parallel node executions. It delegates all AIAgentContextBase methods and properties to the underlying context.

Parameters

Input

The input type of the parallel nodes

Output

The output type of the parallel nodes

Constructors

Link copied to clipboard
constructor(underlyingContextBase: AIAgentContextBase, results: List<ParallelResult<Input, Output>>)

Properties

Link copied to clipboard
open override val agentInput: Any?

Represents the input provided to the agent's execution.

Link copied to clipboard
open override val agentInputType: KType

KType representing the type of the agentInput

Link copied to clipboard
open override val config: AIAgentConfigBase

Represents the configuration for an AI agent.

Link copied to clipboard
open override val environment: AIAgentEnvironment

Represents the environment in which the agent operates.

Link copied to clipboard
open override val id: String

Represents the unique identifier for the agent.

Link copied to clipboard
open override 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

The results of the parallel node executions

Link copied to clipboard
open override 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
open override 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
open override val strategyName: String

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

Functions

Link copied to clipboard

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

Link copied to clipboard
open override fun copy(environment: AIAgentEnvironment, agentInput: Any?, agentInputType: KType, config: AIAgentConfigBase, llm: AIAgentLLMContext, stateManager: AIAgentStateManager, storage: AIAgentStorage, runId: String, strategyId: String, pipeline: AIAgentPipeline): AIAgentContextBase

Creates a copy of the current AIAgentContext with optional overrides for its properties.

Link copied to clipboard
open override fun <Feature : Any> feature(key: AIAgentStorageKey<Feature>): Feature?

Retrieves a feature from the agent's storage using the specified key.

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

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

Link copied to clipboard
open override fun <Feature : Any> featureOrThrow(feature: AIAgentFeature<*, Feature>): Feature

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

Link copied to clipboard
suspend fun <R> fold(initial: R, operation: suspend (acc: R, result: Output) -> R): ParallelNodeExecutionResult<R>

Folds the result output into a single value and leaves the base context.

Link copied to clipboard
open suspend override fun fork(): AIAgentContextBase

Creates a copy of the current AIAgentContext with deep copies of all mutable properties. This method is particularly useful in scenarios like parallel node execution where contexts need to be sent to different threads and then merged back together using replace.

Link copied to clipboard
open override 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
open suspend override fun getHistory(): List<Message>

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

Link copied to clipboard
open override 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
open suspend override fun replace(context: AIAgentContextBase)

Replaces the current context with the provided context. This method is used to update the current context with values from another context, particularly useful in scenarios like parallel node execution where contexts need to be merged.

Link copied to clipboard
suspend fun selectBy(predicate: suspend (Output) -> Boolean): ParallelNodeExecutionResult<Output>

Selects a result based on a predicate.

Link copied to clipboard
suspend fun selectByIndex(selectIndex: suspend (List<Output>) -> Int): ParallelNodeExecutionResult<Output>

Selects a result from a list of outputs based on a provided selection function.

Link copied to clipboard
suspend fun <T : Comparable<T>> selectByMax(function: suspend (Output) -> T): ParallelNodeExecutionResult<Output>

Selects the maximum result based on a given comparison function and returns the corresponding NodeExecutionResult containing the selected output and its associated context.

Link copied to clipboard
open override 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.