AIAgentSubgraph

Represents a subgraph within an AI agent execution strategy capable of processing input and producing output.

A subgraph is a modular component of a larger execution graph, defined by a StartNode as the entry point and a FinishNode as the exit point. The subgraph may implement tool selection strategies, incorporate language model support, and apply custom response processing to tailor its behavior within the broader agent workflow.

Parameters

name

The name of the subgraph.

start

The starting node of the subgraph, which initiates the processing.

finish

The finishing node of the subgraph, which concludes the processing.

toolSelectionStrategy

Strategy determining which tools should be available during this subgraph's execution.

llmModel

Optional LLModel override for the subgraph execution.

llmParams

Optional LLMParams override for the prompt for the subgraph execution.

responseProcessor

Optional ResponseProcessor override for the subgraph execution.

Type Parameters

TInput

The type of input data accepted by the subgraph.

TOutput

The type of output data returned by the subgraph.

Represents a subgraph within an AI agent execution strategy capable of processing input and producing output.

A subgraph is a modular component of a larger execution graph, defined by a StartNode as the entry point and a FinishNode as the exit point. The subgraph may implement tool selection strategies, incorporate language model support, and apply

Represents a subgraph within an AI agent execution strategy capable of processing input and producing output.

A subgraph is a modular component of a larger execution graph, defined by a StartNode as the entry point and a FinishNode as the exit point. The subgraph may implement tool selection strategies, incorporate language model support, and apply

Constructors

Link copied to clipboard
expect constructor(name: String, start: StartNode<TInput>, finish: FinishNode<TOutput>, toolSelectionStrategy: ToolSelectionStrategy, llmModel: LLModel? = null, llmParams: LLMParams? = null, responseProcessor: ResponseProcessor? = null)
actual constructor(name: String, start: StartNode<TInput>, finish: FinishNode<TOutput>, toolSelectionStrategy: ToolSelectionStrategy, llmModel: ERROR CLASS: Symbol not found for LLModel??, llmParams: ERROR CLASS: Symbol not found for LLMParams??, responseProcessor: ERROR CLASS: Symbol not found for ResponseProcessor??)
actual constructor(name: String, start: StartNode<TInput>, finish: FinishNode<TOutput>, toolSelectionStrategy: ToolSelectionStrategy, llmModel: LLModel?, llmParams: LLMParams?, responseProcessor: ResponseProcessor?)

Types

Link copied to clipboard
object Companion

Companion object for AIAgentSubgraph.

Properties

Link copied to clipboard
expect var edges: List<AIAgentEdge<TOutput, *>>

The directed edges connecting this node to other nodes in the AI agent strategy graph. Each edge defines the flow and optional transformation of output data from this node to another.

The directed edges connecting this node to other nodes in the AI agent strategy graph. Each edge defines the flow and optional transformation of output data from this node to another.

The directed edges connecting this node to other nodes in the AI agent strategy graph. Each edge defines the flow and optional transformation of output data from this node to another.

Link copied to clipboard
Link copied to clipboard
val id: String

Represents the unique identifier of the AI agent node.

val id: String

Represents the unique identifier of the AI agent node.

val id: String

Represents the unique identifier of the AI agent node.

Link copied to clipboard
open override val inputType: TypeToken

The TypeToken of the TInput

open override val inputType: ai/koog/serialization/TypeToken

The TypeToken of the TInput

open override val inputType: TypeToken

The TypeToken of the TInput

Link copied to clipboard
open override val name: String
open override val name: String
open override val name: String
Link copied to clipboard
open override val outputType: TypeToken

The TypeToken of the TOutput

open override val outputType: ai/koog/serialization/TypeToken

The TypeToken of the TOutput

open override val outputType: TypeToken

The TypeToken of the TOutput

Link copied to clipboard
expect val start: StartNode<TInput>

Functions

Link copied to clipboard
expect open fun addEdge(edge: AIAgentEdge<TOutput, *>)

Adds a directed edge from the current node, enabling connections between this node and other nodes in the AI agent strategy graph.

open fun addEdge(edge: AIAgentEdge<TOutput, *>)

Adds a directed edge from the current node, enabling connections between this node and other nodes in the AI agent strategy graph.

open fun addEdge(edge: AIAgentEdge<TOutput, *>)

Adds a directed edge from the current node, enabling connections between this node and other nodes in the AI agent strategy graph.

Link copied to clipboard
open override fun enforceExecutionPoint(node: AIAgentNodeBase<*, *>, input: Any? = null)

Enforces execution to start at the specified node with the given input, overriding the default execution flow.

open override fun enforceExecutionPoint(node: AIAgentNodeBase<*, *>, input: Any? = null)

Enforces execution to start at the specified node with the given input, overriding the default execution flow.

open override fun enforceExecutionPoint(node: AIAgentNodeBase<*, *>, input: Any? = null)

Enforces execution to start at the specified node with the given input, overriding the default execution flow.

Link copied to clipboard
expect open suspend override fun execute(context: AIAgentGraphContextBase, input: TInput): TOutput?

Executes the subgraph for the given input within context.

open suspend override fun execute(context: AIAgentGraphContextBase, input: TInput): TOutput?

Executes the subgraph for the given input within context.

open suspend override fun execute(context: AIAgentGraphContextBase, input: TInput): TOutput?

Executes the subgraph for the given input within context.

Link copied to clipboard
suspend fun executeUnsafe(context: AIAgentGraphContextBase, input: Any?): Any?

Executes the node operation using the provided execution context and input, bypassing static type checks. This method internally performs an unchecked cast of input to TInput and delegates to execute. The caller is responsible for ensuring that input is actually assignable to TInput; otherwise a ClassCastException may be thrown at the call site or later during execution.

suspend fun executeUnsafe(context: AIAgentGraphContextBase, input: Any?): Any?

Executes the node operation using the provided execution context and input, bypassing static type checks. This method internally performs an unchecked cast of input to TInput and delegates to execute. The caller is responsible for ensuring that input is actually assignable to TInput; otherwise a ClassCastException may be thrown at the call site or later during execution.

suspend fun executeUnsafe(context: AIAgentGraphContextBase, input: Any?): Any?

Executes the node operation using the provided execution context and input, bypassing static type checks. This method internally performs an unchecked cast of input to TInput and delegates to execute. The caller is responsible for ensuring that input is actually assignable to TInput; otherwise a ClassCastException may be thrown at the call site or later during execution.

Link copied to clipboard

Creates a directed edge from this AIAgentNodeBase to another AIAgentNodeBase, allowing data to flow from the output of the current node to the input of the specified node.

Creates a directed edge from this AIAgentNodeBase to another AIAgentNodeBase, allowing data to flow from the output of the current node to the input of the specified node.

Creates a directed edge from this AIAgentNodeBase to another AIAgentNodeBase, allowing data to flow from the output of the current node to the input of the specified node.

Link copied to clipboard
open override fun getExecutionPoint(): ExecutionPoint?

Retrieves the current execution point, which consists of a specific node in the execution graph and an optional input. If no forced node is defined, the method returns null.

open override fun getExecutionPoint(): ExecutionPoint?

Retrieves the current execution point, which consists of a specific node in the execution graph and an optional input. If no forced node is defined, the method returns null.

open override fun getExecutionPoint(): ExecutionPoint?

Retrieves the current execution point, which consists of a specific node in the execution graph and an optional input. If no forced node is defined, the method returns null.

Link copied to clipboard
open override fun resetExecutionPoint()

Resets the currently enforced execution point for the AI agent, including clearing any forced node and input data. Once the execution point is reset, the system will revert to its default execution behavior without targeting a specific node explicitly.

open override fun resetExecutionPoint()

Resets the currently enforced execution point for the AI agent, including clearing any forced node and input data. Once the execution point is reset, the system will revert to its default execution behavior without targeting a specific node explicitly.

open override fun resetExecutionPoint()

Resets the currently enforced execution point for the AI agent, including clearing any forced node and input data. Once the execution point is reset, the system will revert to its default execution behavior without targeting a specific node explicitly.

Link copied to clipboard
expect suspend fun resolveEdge(context: AIAgentGraphContextBase, nodeOutput: TOutput): AIAgentNodeBase.ResolvedEdge?

Resolves the edge associated with the provided node output and execution context. Iterates through available edges and identifies the first edge that can successfully process the given node output within the provided context. If a resolvable edge is found, it returns a ResolvedEdge containing the edge and its output. Otherwise, returns null.

Resolves the edge associated with the provided node output and execution context. Iterates through available edges and identifies the first edge that can successfully process the given node output within the provided context. If a resolvable edge is found, it returns a ResolvedEdge containing the edge and its output. Otherwise, returns null.

Resolves the edge associated with the provided node output and execution context. Iterates through available edges and identifies the first edge that can successfully process the given node output within the provided context. If a resolvable edge is found, it returns a ResolvedEdge containing the edge and its output. Otherwise, returns null.