Package-level declarations

Types

Link copied to clipboard

A concrete implementation of the HistoryCompressionStrategy that splits the session's prompt into chunks of a predefined size and generates summaries (TL;DR) for each chunk.

Link copied to clipboard
data class Concept(val keyword: String, val description: String, val factType: FactType)

Represents a distinct piece of knowledge that an agent can remember and recall. Concepts are the fundamental building blocks of the agent's memory system, allowing structured storage and retrieval of information across different contexts and time periods.

Link copied to clipboard
sealed interface Fact

Represents stored information about a specific concept at a point in time. Facts are the actual data points stored in the memory system, always associated with their originating concept and creation timestamp for temporal reasoning.

Link copied to clipboard

A history compression strategy that extracts structured facts about predefined concepts from the current conversation history using an LLM, then replaces the full history with a compact assistant message containing those extracted facts.

Link copied to clipboard

Defines how information should be stored and retrieved for a concept in the memory system. This type system helps organize and structure the knowledge representation in the agent's memory.

A strategy for compressing history by retaining only the last n messages in a session.

Link copied to clipboard

A strategy for compressing message histories using a specified timestamp as a reference point. This strategy removes messages that occurred before a given timestamp and creates a summarized context for further interactions.

Link copied to clipboard

Represents an abstract strategy for compressing the history of messages in a AIAgentLLMWriteSession. Different implementations define specific approaches to reducing the context size while maintaining key information.

Link copied to clipboard
data class ModeratedMessage(val message: Message, val moderationResult: ModerationResult)

Represents a message that has undergone moderation and the result of the moderation.

Link copied to clipboard
data class MultipleFacts(val concept: Concept, val timestamp: Long, val values: List<String>) : Fact

Stores multiple related pieces of information about a concept. Used when the concept represents a collection of related facts that should be stored and retrieved together.

Link copied to clipboard

Wraps a list of ReceivedToolResult values returned by the agent environment after tool execution.

Link copied to clipboard
data class SingleFact(val concept: Concept, val timestamp: Long, val value: String) : Fact

Stores a single piece of information about a concept. Used when the concept represents a singular, atomic piece of knowledge that doesn't need to be broken down into multiple components.

Link copied to clipboard
data class ToolCalls(val toolCalls: List<MessagePart.Tool.Call>)

Wraps a list of pending tool calls produced by an LLM response.

Link copied to clipboard

Wraps a list of tool results ready to be sent back to the LLM.

WholeCompressionStrategyWithMultipleSystemMessages is a concrete implementation of the HistoryCompressionStrategy that handles scenarios where the conversation history contains multiple system messages.

Link copied to clipboard

WholeHistory is a concrete implementation of the HistoryCompressionStrategy that encapsulates the logic for compressing entire conversation history into a succinct summary (TL;DR) and composing the necessary messages to create a streamlined prompt suitable for language model interactions.

Functions

Link copied to clipboard
suspend fun <T> AIAgentGraphContextBase.appendPromptImpl(input: T, body: PromptBuilder.() -> Unit): T

InternalAgentsApi method. Appends a prompt to the current LLM session.

Link copied to clipboard

Applies a transformation to the intermediate output of the edge builder and filters the received tool results based on the provided condition. This function is used to handle tool results as a part of the AI agent's edge flow within the DSL.

Link copied to clipboard
Link copied to clipboard

InternalAgentsApi method. Executes a single tool with the provided arguments and returns the result.

Link copied to clipboard
suspend fun <T> AIAgentGraphContextBase.llmCompressHistoryImpl(input: T, retrievalModel: LLModel?, strategy: HistoryCompressionStrategy, preserveMemory: Boolean): T

InternalAgentsApi method. Performs LLM history compression.

Link copied to clipboard
inline fun <T> nodeAppendPrompt(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
inline fun <T> nodeDoNothing(name: String? = null): AIAgentNodeDelegate<T, T>

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

Link copied to clipboard

A node that executes a single MessagePart.Tool.Call and returns the ReceivedToolResult without writing anything into the LLM session.

inline fun <ToolArg, TResult> nodeExecuteSingleTool(name: String? = null, tool: Tool<ToolArg, TResult>, doAppendPrompt: Boolean = true): AIAgentNodeDelegate<ToolArg, SafeTool.Result<TResult>>

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

Link copied to clipboard

A node that executes the tool calls in a ToolCalls input and returns the raw ReceivedToolResults without writing them into the LLM session.

Link copied to clipboard
inline fun <T> 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 nodeLLMModerateMessage(name: String? = null, moderatingModel: LLModel? = null, includeCurrentPrompt: Boolean = false): AIAgentNodeDelegate<Message, ModeratedMessage>

A node that runs content moderation on an incoming Message using the LLM.

Link copied to clipboard
fun nodeLLMModerateText(name: String? = null, moderatingModel: LLModel? = null, includeCurrentPrompt: Boolean = false): AIAgentNodeDelegate<String, ModeratedMessage>

A node that runs content moderation on an incoming text using the LLM.

Link copied to clipboard

A node that appends a user text message to the prompt and requests a response from the LLM.

Link copied to clipboard

A node that appends a user text message to the prompt and requests a response from the LLM, forcing it to call exactly the specified tool.

Link copied to clipboard

A node that appends a user text message to the prompt and requests multiple completion choices from the LLM, returning them as an LLMChoice.

Link copied to clipboard

A node that appends a user text message to the prompt and requests a response from the LLM, forcing it to call one of the available tools (no plain-text replies allowed).

Link copied to clipboard
fun nodeLLMRequestStreaming(name: String? = null, structureDefinition: StructureDefinition? = null): AIAgentNodeDelegate<String, Flow<StreamFrame>>

A node that appends a user text message to the prompt and requests a streaming response from the LLM, returning raw StreamFrame elements.

fun <T> nodeLLMRequestStreaming(name: String? = null, structureDefinition: StructureDefinition? = null, transformStreamData: suspend (Flow<StreamFrame>) -> Flow<T>): AIAgentNodeDelegate<String, Flow<T>>

A node that appends a user text message to the prompt and requests a streaming response from the LLM, applying transformStreamData to convert the raw StreamFrame flow into a flow of T.

Link copied to clipboard

A node that appends a user text message to the prompt and requests a structured response from the LLM using the provided config.

inline fun <T> nodeLLMRequestStructured(name: String? = null, examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): AIAgentNodeDelegate<String, Result<StructuredResponse<T>>>

A node that appends a user text message to the prompt and requests a structured response from the LLM, inferring the output schema from the reified type T.

Link copied to clipboard

A node that appends a user text message to the prompt and requests a response from the LLM, without exposing any tools (pure text response only).

Link copied to clipboard

A node that appends a Message.User to the prompt and requests a response from the LLM.

Link copied to clipboard

A node that appends a Message.User to the prompt and requests a response from the LLM, forcing it to call exactly the specified tool.

Link copied to clipboard

A node that appends a Message.User to the prompt and requests multiple completion choices from the LLM, returning them as an LLMChoice.

Link copied to clipboard

A node that appends a Message.User to the prompt and requests a response from the LLM, forcing it to call one of the available tools (no plain-text replies allowed).

Link copied to clipboard

A node that appends a Message.User to the prompt and requests a streaming response from the LLM, returning raw StreamFrame elements.

fun <T> nodeLLMSendMessageStreaming(name: String? = null, structureDefinition: StructureDefinition? = null, transformStreamData: suspend (Flow<StreamFrame>) -> Flow<T>): AIAgentNodeDelegate<Message.User, Flow<T>>

A node that appends a Message.User to the prompt and requests a streaming response from the LLM, applying transformStreamData to convert the raw StreamFrame flow into a flow of T.

Link copied to clipboard

A node that appends a Message.User to the prompt and requests a structured response from the LLM using the provided config.

inline fun <T> nodeLLMSendMessageStructured(name: String? = null, examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): AIAgentNodeDelegate<Message.User, Result<StructuredResponse<T>>>

A node that appends a Message.User to the prompt and requests a structured response from the LLM, inferring the output schema from the reified type T.

Link copied to clipboard

A node that appends a Message.User to the prompt and requests a response from the LLM, without exposing any tools (pure text response only).

Link copied to clipboard

A node that appends tool results from ReceivedToolResults to the prompt as a user message and requests a follow-up response from the LLM.

Link copied to clipboard

A node that appends tool results from ReceivedToolResults to the prompt as a user message and requests a follow-up response from the LLM, forcing it to call exactly the specified tool.

Link copied to clipboard

A node that appends tool results from ReceivedToolResults to the prompt as a user message and requests multiple completion choices from the LLM, returning them as an LLMChoice.

Link copied to clipboard

A node that appends tool results from ReceivedToolResults to the prompt as a user message and requests a follow-up response from the LLM, forcing it to call one of the available tools.

Link copied to clipboard

A node that appends tool results to the prompt and requests a streaming response from the LLM, returning raw StreamFrame elements.

Link copied to clipboard

A node that appends tool results from ReceivedToolResults to the prompt as a user message and requests a follow-up response from the LLM, without exposing any tools (pure text response only).

Link copied to clipboard

Creates a node that sets up a structured output for an AI agent subgraph.

Link copied to clipboard

Defines a handler to process failure cases in a directed edge strategy by applying a condition to filter intermediate results of type SafeTool.Result.Failure. This method is used to specialize processing for failure results and to propagate or transform them based on the provided condition.

Link copied to clipboard
Link copied to clipboard

Filters and transforms the intermediate outputs of the AI agent node based on the success results of a tool operation.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Creates an edge that filters assistant messages containing tool calls, based on a custom condition. The default condition onToolCalls { true } will create a conditional edge checking that there at list one tool call The custom condition onToolCalls { it.tool == "exit" } will create a conditional edge checking that there is tool call with the name "exit"

Link copied to clipboard
suspend fun <T> AIAgentGraphContextBase.requestStreamingImpl(input: String, structureDefinition: StructureDefinition? = null, transformStreamData: suspend (Flow<StreamFrame>) -> Flow<T>): Flow<T>

InternalAgentsApi method. Appends a Message.User with given text to the prompt and requests a streaming response from the LLM.

Link copied to clipboard

InternalAgentsApi method. Sets up structured output for an AI agent subgraph.