FunctionalAIAgent

class FunctionalAIAgent<Input, Output>(val promptExecutor: PromptExecutor, val agentConfig: AIAgentConfig, val strategy: AIAgentFunctionalStrategy<Input, Output>, val toolRegistry: ToolRegistry = ToolRegistry.EMPTY, id: String? = null, val clock: Clock = Clock.System, val installFeatures: FunctionalAIAgent.FeatureContext.() -> Unit = {}) : AIAgentBase<Input, Output, AIAgentFunctionalContext> (source)

Represents the core AI agent for processing input and generating output using a defined configuration, toolset, and prompt execution pipeline.

Parameters

id

Unique identifier for the agent. Random UUID will be generated if set to null.

Type Parameters

Input

The type of input data expected by the agent.

Output

The type of output data produced by the agent.

Constructors

Link copied to clipboard
constructor(promptExecutor: PromptExecutor, agentConfig: AIAgentConfig, strategy: AIAgentFunctionalStrategy<Input, Output>, toolRegistry: ToolRegistry = ToolRegistry.EMPTY, id: String? = null, clock: Clock = Clock.System, installFeatures: FunctionalAIAgent.FeatureContext.() -> Unit = {})

Types

Link copied to clipboard

Represents a context for managing and configuring features in an AI agent. Provides functionality to install and configure features into a specific instance of an AI agent.

Properties

Link copied to clipboard
open override val agentConfig: AIAgentConfig

The configuration for the agent, including the prompt structure and execution parameters.

Link copied to clipboard

The clock used to calculate message timestamps

Link copied to clipboard
override val id: String

Represents the unique identifier for the AI agent.

Link copied to clipboard

Lambda for installing additional features within the agent environment.

Link copied to clipboard

Represents the pipeline used by the AI agent for processing tasks or data.

Link copied to clipboard

The executor responsible for processing prompts and interacting with language models.

Link copied to clipboard

The strategy for processing input and generating output.

Link copied to clipboard

The registry of tools available for the agent. Defaults to an empty registry if not specified.

Functions

Link copied to clipboard
inline fun <Input, Output> AIAgent<Input, Output>.asTool(agentName: String, agentDescription: String, inputDescription: String? = null, inputSerializer: KSerializer<Input> = serializer(), outputSerializer: KSerializer<Output> = serializer(), json: Json = Json.Default): Tool<AIAgentTool.AgentToolInput<Input>, AIAgentTool.AgentToolResult<Output>>

Converts the current AI agent into a tool to allow using it in other agents as a tool.

Link copied to clipboard
open suspend override fun close()

Closes the AI Agent and performs necessary cleanup operations.

Link copied to clipboard

Creates a new AIAgentRunSession for executing the agent with the given input.

Link copied to clipboard
open suspend override fun prepareContext(agentInput: Input, runId: String, eventId: String): AIAgentFunctionalContext

Prepares and initializes the agent context required to handle the given input and run ID.

Link copied to clipboard
open suspend override fun run(agentInput: Input, sessionId: String? = null): Output

Executes the agent's main functionality, coordinating with various components such as pipelines and strategies. Ensures the agent is run in a thread-safe manner using locking mechanisms.