AIAgentGraphStrategy

Represents a strategy for managing and executing AI agent workflows built as subgraphs of interconnected nodes.

Represents a strategy for managing and executing AI agent workflows built as subgraphs of interconnected nodes.

Represents a strategy for managing and executing AI agent workflows built as subgraphs of interconnected nodes.

Constructors

Link copied to clipboard
expect constructor(name: String, nodeStart: StartNode<TInput>, nodeFinish: FinishNode<TOutput>, toolSelectionStrategy: ToolSelectionStrategy, serializer: Json = Json { prettyPrint = true })
actual constructor(name: String, nodeStart: StartNode<TInput>, nodeFinish: FinishNode<TOutput>, toolSelectionStrategy: ToolSelectionStrategy, serializer: ERROR CLASS: Symbol not found for Json)
actual constructor(name: String, nodeStart: StartNode<TInput>, nodeFinish: FinishNode<TOutput>, toolSelectionStrategy: ToolSelectionStrategy, serializer: Json)

Types

Link copied to clipboard
object Companion

Companion object for the AIAgentGraphStrategy class.

Properties

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

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

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

Represents the directed edges connecting the current node in the AI agent strategy graph to other nodes. Each edge defines the flow and 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

Represents the metadata of the subgraph associated with the AI agent strategy.

Represents the metadata of the subgraph associated with the AI agent strategy.

Represents the metadata of the subgraph associated with the AI agent strategy.

Link copied to clipboard
open override val name: String

The unique identifier for the strategy.

open override val name: String

The unique identifier for the strategy.

open override val name: String

The unique identifier for the strategy.

Link copied to clipboard

The finishing node of the strategy, marking the subgraph's endpoint.

The finishing node of the strategy, marking the subgraph's endpoint.

The finishing node of the strategy, marking the subgraph's endpoint.

Link copied to clipboard

The starting node of the strategy, initiating the subgraph execution. By default, the start node gets the agent input and returns

The starting node of the strategy, initiating the subgraph execution. By default, the start node gets the agent input and returns

The starting node of the strategy, initiating the subgraph execution. By default, the start node gets the agent input and returns

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

Extension function to generate a Mermaid diagram from an agent graph strategy.

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

Sets a forced node for the entity.

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

Sets a forced node for the entity.

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

Sets a forced node for the entity.

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

Executes the AI agent's strategy using the provided context and input.

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

Executes the AI agent's strategy using the provided context and input.

open fun execute(context: AIAgentGraphContextBase, input: TInput, executorService: ExecutorService? = null): TOutput?
open suspend override fun execute(context: AIAgentGraphContextBase, input: TInput): TOutput?

Executes the AI agent's strategy using the provided context and input.

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

Executes the node operation using the provided execution context and input, bypassing type safety checks. This method internally calls the type-safe execute method after casting the input.

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

Executes the node operation using the provided execution context and input, bypassing type safety checks. This method internally calls the type-safe execute method after casting the input.

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

Executes the node operation using the provided execution context and input, bypassing type safety checks. This method internally calls the type-safe execute method after casting the input.

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

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.

Link copied to clipboard
suspend fun setExecutionPoint(nodePath: String, input: JSONElement, agentContext: AIAgentGraphContextBase)

Finds and sets the node for the strategy based on the provided context.

suspend fun setExecutionPoint(nodePath: String, input: ai/koog/serialization/JSONElement, agentContext: AIAgentGraphContextBase)

Finds and sets the node for the strategy based on the provided context.

suspend fun setExecutionPoint(nodePath: String, input: JSONElement, agentContext: AIAgentGraphContextBase)

Finds and sets the node for the strategy based on the provided context.

Link copied to clipboard
suspend fun setExecutionPointAfterNode(nodePath: String, output: JSONElement, agentContext: AIAgentGraphContextBase)
suspend fun setExecutionPointAfterNode(nodePath: String, output: JsonElement, agentContext: AIAgentGraphContextBase)

Finds and sets the node for the strategy based on the provided context.

suspend fun setExecutionPointAfterNode(nodePath: String, output: ai/koog/serialization/JSONElement, agentContext: AIAgentGraphContextBase)
suspend fun setExecutionPointAfterNode(nodePath: String, output: kotlinx/serialization/json/JsonElement, agentContext: AIAgentGraphContextBase)

Finds and sets the node for the strategy based on the provided context.

suspend fun setExecutionPointAfterNode(nodePath: String, output: JSONElement, agentContext: AIAgentGraphContextBase)
suspend fun setExecutionPointAfterNode(nodePath: String, output: JsonElement, agentContext: AIAgentGraphContextBase)

Finds and sets the node for the strategy based on the provided context.

Link copied to clipboard

Constructs an instance of AIAgentEventGraph by converting the metadata information of the current AIAgentGraphStrategy into its graph representation. The method creates nodes and edges that define the structure and flow of execution for the underlying AI agent strategy.