AIAgentSubgraphBuilderBase

Abstract base class for building AI agent subgraphs.

This class provides utilities for defining and connecting nodes within a subgraph, constructing custom subgraphs with specified tools or tool selection strategies, and managing the structural relationships between subgraph nodes.

Parameters

Input

The input type expected by the starting node of the subgraph.

Output

The output type produced by the finishing node of the subgraph.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Represents the "finish" node in the AI agent's subgraph structure. This node indicates the endpoint of the subgraph and acts as a terminal stage where the workflow stops.

Link copied to clipboard
abstract val nodeStart: StartNode<Input>

Represents the starting node of the subgraph in the AI agent's strategy graph.

Functions

Link copied to clipboard
Link copied to clipboard
inline fun <Input, Output> node(name: String? = null, noinline execute: suspend AIAgentContextBase.(input: Input) -> Output): AIAgentNodeDelegate<Input, Output>

Defines a new node in the agent's stage, representing a unit of execution that takes an input and produces an output.

Link copied to clipboard

A pass-through node that does nothing and returns input as output

Link copied to clipboard

A node that executes multiple tool calls. These calls can optionally be executed in parallel.

Link copied to clipboard

Creates a node in the AI agent subgraph that processes a collection of tool calls, executes them, and sends back the results to the downstream process. The tools can be executed either in parallel or sequentially based on the provided configuration.

Link copied to clipboard

A node that calls a specific tool directly using the provided arguments.

Link copied to clipboard

A node that executes a tool call and returns its result.

Link copied to clipboard
inline fun <T> AIAgentSubgraphBuilderBase<*, *>.nodeLLMCompressHistory(name: String? = null, strategy: HistoryCompressionStrategy = HistoryCompressionStrategy.WholeHistory, retrievalModel: LLModel? = null, preserveMemory: Boolean = true): AIAgentNodeDelegate<T, T>

A node that compresses the current LLM prompt (message history) into a summary, replacing messages with a TLDR.

Link copied to clipboard
fun AIAgentSubgraphBuilderBase<*, *>.nodeLLMModerateMessage(name: String? = null, moderatingModel: LLModel? = null, includeCurrentPrompt: Boolean = false): AIAgentNodeDelegate<Message, ModeratedMessage>

A node that moderates only a single input message using a specified language model.

Link copied to clipboard

A node that appends a user message to the LLM prompt and gets a response with optional tool usage.

Link copied to clipboard

A node that appends a user message to the LLM prompt and gets multiple LLM responses with tool calls enabled.

Link copied to clipboard

A node that appends a user message to the LLM prompt and streams LLM response without transformation.

fun <T> AIAgentSubgraphBuilderBase<*, *>.nodeLLMRequestStreaming(name: String? = null, structureDefinition: StructuredDataDefinition? = null, transformStreamData: suspend (Flow<String>) -> Flow<T>): AIAgentNodeDelegate<String, Flow<T>>

A node that appends a user message to the LLM prompt, streams LLM response and transforms the stream data.

Link copied to clipboard
inline fun <T> AIAgentSubgraphBuilderBase<*, *>.nodeLLMRequestStructured(name: String? = null, structure: StructuredData<T>, retries: Int, fixingModel: LLModel): AIAgentNodeDelegate<String, Result<StructuredResponse<T>>>

A node that appends a user message to the LLM prompt and requests structured data from the LLM with error correction capabilities.

Link copied to clipboard

A node that that appends a user message to the LLM prompt and forces the LLM to use a specific tool.

A node that appends a user message to the LLM prompt and forces the LLM to use a specific tool.

Link copied to clipboard

A node that appends a user message to the LLM prompt and gets a response where the LLM can only call tools.

Link copied to clipboard

A node that adds multiple tool results to the prompt and gets multiple LLM responses.

Link copied to clipboard

A node that sends multiple tool execution results to the LLM and gets multiple LLM choices.

Link copied to clipboard

A node that adds a tool result to the prompt and requests an LLM response.

Link copied to clipboard

A node that chooses an LLM choice based on the given strategy.

Link copied to clipboard
inline fun <T> AIAgentSubgraphBuilderBase<*, *>.nodeUpdatePrompt(name: String? = null, noinline body: PromptBuilder.() -> Unit): AIAgentNodeDelegate<T, T>

A node that adds messages to the LLM prompt using the provided prompt builder. The input is passed as it is to the output.

Link copied to clipboard

Creates a node that executes multiple nodes in parallel.

Link copied to clipboard
inline fun <Input, Output> subgraph(name: String? = null, toolSelectionStrategy: ToolSelectionStrategy = ToolSelectionStrategy.ALL, llmModel: LLModel? = null, llmParams: LLMParams? = null, define: AIAgentSubgraphBuilderBase<Input, Output>.() -> Unit): AIAgentSubgraphDelegate<Input, Output>

Creates a subgraph with a specified tool selection strategy.

inline fun <Input, Output> subgraph(name: String? = null, tools: List<Tool<*, *>>, llmModel: LLModel? = null, llmParams: LLMParams? = null, define: AIAgentSubgraphBuilderBase<Input, Output>.() -> Unit): AIAgentSubgraphDelegate<Input, Output>

Creates a subgraph with specified tools.

Link copied to clipboard