FunctionalAIAgentService

A service for managing functional AI agents that operate based on a specified execution strategy.

This class provides the infrastructure for creating and managing functional AI agents. It integrates an execution strategy with associated input and output types, a tool registry for additional functionalities, and a customizable feature installation context.

Parameters

Input

The type of input data that the functional AI agent will process.

Output

The type of output data produced by the functional AI agent.

Constructors

Link copied to clipboard
constructor(promptExecutor: PromptExecutor, agentConfig: AIAgentConfig, strategy: AIAgentFunctionalStrategy<Input, Output>, toolRegistry: ToolRegistry, installFeatures: FunctionalAIAgent.FeatureContext.() -> Unit)

Properties

Link copied to clipboard
open override val agentConfig: AIAgentConfig

The configuration settings for the AI agent, including model and prompt behavior.

Link copied to clipboard
open override val promptExecutor: PromptExecutor

The executor responsible for handling and executing prompts.

Link copied to clipboard

The functional strategy defining the agent's iteration logic and processing behavior.

Link copied to clipboard
open override val toolRegistry: ToolRegistry

Represents the central repository or registry for managing tools within the system.

Functions

Link copied to clipboard
suspend override fun agentById(id: String): FunctionalAIAgent<Input, Output>?

Retrieves an AI agent managed by this service based on the provided unique identifier.

Link copied to clipboard
open suspend fun closeAll()

Closes all AI agents currently managed by the service.

Link copied to clipboard
suspend override fun createAgent(id: String?, additionalToolRegistry: ToolRegistry, agentConfig: AIAgentConfig, clock: Clock): FunctionalAIAgent<Input, Output>

Creates and registers a new managed AI agent with the specified configuration and tool registry.

Link copied to clipboard
open suspend fun createAgentAndRun(agentInput: Input, id: String? = null, additionalToolRegistry: ToolRegistry = this.toolRegistry, agentConfig: AIAgentConfig = this.agentConfig, clock: Clock = Clock.System): Output

Creates an AI agent with the specified configuration and runs it using the provided input.

Link copied to clipboard
inline fun <Input, Output> AIAgentService<Input, Output, *>.createAgentTool(agentName: String, agentDescription: String, inputDescription: String? = null, inputSerializer: KSerializer<Input> = serializer(), outputSerializer: KSerializer<Output> = serializer(), parentAgentId: String? = null, clock: Clock = Clock.System): Tool<Input, AIAgentTool.AgentToolResult<Output>>

Creates an AIAgent and converts it to a Tool that can be used by other AI Agents.

Link copied to clipboard
open override fun createManagedAgent(id: String?, additionalToolRegistry: ToolRegistry, agentConfig: AIAgentConfig, clock: Clock): FunctionalAIAgent<Input, Output>

Creates and returns a managed instance of FunctionalAIAgent.

Link copied to clipboard

Retrieves a list of all currently active AI agents managed by the service.

Link copied to clipboard
open suspend override fun listAllAgents(): List<FunctionalAIAgent<Input, Output>>

Retrieves a list of all AI agents currently managed by the service, regardless of their state (e.g., active, inactive, or finished).

Link copied to clipboard

Retrieves a list of all agents that have already finished their task.

Link copied to clipboard

Retrieves a list of inactive AI agents managed by this service.

Link copied to clipboard
suspend override fun removeAgent(agent: FunctionalAIAgent<Input, Output>): Boolean

Removes the specified AI agent from the managed collection.

Link copied to clipboard
suspend override fun removeAgentWithId(id: String): Boolean

Removes a managed AI agent identified by the specified unique identifier.