AIAgentConfig

expect class AIAgentConfig(prompt: Prompt, model: LLModel, maxAgentIterations: Int, missingToolsConversionStrategy: MissingToolsConversionStrategy = MissingToolsConversionStrategy.Missing(ToolCallDescriber.JSON), responseProcessor: ResponseProcessor? = null, serializer: JSONSerializer = KotlinxSerializer()) : AIAgentConfigBase(source)

Configuration class for an AI agent that specifies the prompt, execution parameters, and behavior.

This class is responsible for defining the various settings and components required for an AI agent to operate. It includes the prompt configuration, iteration limits, and strategies for handling missing tools during execution.

Parameters

prompt

The initial prompt configuration for the agent, encapsulating messages, model, and parameters.

model

The model to use for the agent's prompt execution

maxAgentIterations

The maximum number of iterations allowed for an agent during its execution to prevent infinite loops.

missingToolsConversionStrategy

Strategy used to determine how tool calls, present in the prompt but lacking definitions, are handled during agent execution. This property provides a mechanism to convert or format missing tool calls and result messages when they occur, typically due to differences in tool sets between steps or subgraphs while the same history is reused. This ensures the prompt remains consistent and readable for the model, even with undefined tools.

responseProcessor

Optional processor for the agent's responses. If specified, will modify the responses from the llm.

serializer

Optional serializer to (de)serialize tool arguments and results. Defaults to KotlinxSerializer

actual class AIAgentConfig(val prompt: Prompt, val model: LLModel, val maxAgentIterations: Int, val missingToolsConversionStrategy: MissingToolsConversionStrategy, val responseProcessor: ResponseProcessor?, val serializer: JSONSerializer) : AIAgentConfigBase(source)
actual class AIAgentConfig(val prompt: Prompt, val model: LLModel, val maxAgentIterations: Int, val missingToolsConversionStrategy: MissingToolsConversionStrategy, val responseProcessor: ResponseProcessor?, val serializer: JSONSerializer) : AIAgentConfigBase(source)

Constructors

Link copied to clipboard
expect constructor(prompt: Prompt, model: LLModel, maxAgentIterations: Int, missingToolsConversionStrategy: MissingToolsConversionStrategy = MissingToolsConversionStrategy.Missing(ToolCallDescriber.JSON), responseProcessor: ResponseProcessor? = null, serializer: JSONSerializer = KotlinxSerializer())
constructor(prompt: Prompt, model: LLModel, maxAgentIterations: Int, agentStrategyExecutorService: ERROR CLASS: Symbol not found for ExecutorService??, llmRequestExecutorService: ERROR CLASS: Symbol not found for ExecutorService?? = null, missingToolsConversionStrategy: MissingToolsConversionStrategy = MissingToolsConversionStrategy.Missing(ToolCallDescriber.JSON), responseProcessor: ResponseProcessor? = null, serializer: JSONSerializer = JacksonSerializer())
actual constructor(prompt: Prompt, model: LLModel, maxAgentIterations: Int, missingToolsConversionStrategy: MissingToolsConversionStrategy, responseProcessor: ResponseProcessor?, serializer: JSONSerializer)
actual constructor(prompt: Prompt, model: LLModel, maxAgentIterations: Int, missingToolsConversionStrategy: MissingToolsConversionStrategy, responseProcessor: ResponseProcessor?, serializer: JSONSerializer)

Types

Link copied to clipboard
expect object Companion

Companion object for providing utility methods related to AIAgentConfig.

actual object Companion
actual object Companion

Properties

Link copied to clipboard
@get:JvmName(name = "maxAgentIterations")
expect val maxAgentIterations: Int

Specifies the maximum number of iterations an AI agent is allowed to execute.

Link copied to clipboard
@get:JvmName(name = "missingToolsConversionStrategy")
expect val missingToolsConversionStrategy: MissingToolsConversionStrategy

Defines the strategy for converting tool calls in the prompt when some tool definitions are missing in the request. This is particularly relevant when managing multi-stage processing or subgraphs where tools used in different

Link copied to clipboard
@get:JvmName(name = "model")
expect open override val model: LLModel

Specifies the Large Language Model (LLM) configuration to be used by the AI agent.

actual open override val model: LLModel

Specifies the Large Language Model (LLM) used by the AI agent for generating responses.

actual open override val model: LLModel

Specifies the Large Language Model (LLM) used by the AI agent for generating responses.

Link copied to clipboard
@get:JvmName(name = "prompt")
expect open override val prompt: Prompt

The prompt configuration used in the AI agent settings.

actual open override val prompt: Prompt

Defines the Prompt to be used in the AI agent's configuration.

actual open override val prompt: Prompt

Defines the Prompt to be used in the AI agent's configuration.

Link copied to clipboard
@get:JvmName(name = "responseProcessor")
expect val responseProcessor: ResponseProcessor?

The response processor used for handling and modifying responses generated by LLM.

Link copied to clipboard
@get:JvmName(name = "serializer")
expect val serializer: JSONSerializer

Serializer to (de)serialize tool arguments and results.

actual val serializer: JSONSerializer
actual val serializer: JSONSerializer

Functions

Link copied to clipboard
fun <T> AIAgentConfig.runOnLLMDispatcher(executorService: ERROR CLASS: Symbol not found for ExecutorService?? = null, block: suspend () -> T): T

Executes the given suspending block of code on the LLM dispatcher (suitable for IO / LLM communication) derived from the provided executorService, or falls back to Dispatchers.IO if none is supplied.

Link copied to clipboard
fun <T> AIAgentConfig.runOnStrategyDispatcher(executorService: ERROR CLASS: Symbol not found for ExecutorService?? = null, block: suspend () -> T): T

Executes a given suspending block of code within a coroutine context on a strategy dispatcher that is determined by the provided executorService . If no executorService is supplied, it defaults to the AIAgentConfig.strategyExecutorService or falls back to Dispatchers.Default if none is configured.

Link copied to clipboard
suspend fun <T> AIAgentConfig.submitToMainDispatcher(block: () -> T): T

Submits a block of code to the main dispatcher for execution.