AIAgentServiceBase

Abstract base class for implementing an AI Agent Service. This class provides foundational functionality for managing and interacting with AI agents.

The class maintains a list of AI agents under its management and defines common operations, such as creation, removal, querying, and shutting down agents. Concrete implementations are expected to define the behavior for creating managed agents.

Parameters

Input

the input type expected by the AI agents.

Output

the output type expected from the AI agents.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Holds the configuration details for an AI agent.

Link copied to clipboard

Represents an instance of PromptExecutor responsible for executing prompt-based operations.

Link copied to clipboard

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

Functions

Link copied to clipboard
suspend override fun agentById(id: String): AIAgent<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?, clock: Clock): AIAgent<Input, Output>

Creates and registers a new AI agent using the provided agent ID and clock.

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

Creates a new AI agent with the specified optional parameters (id, clock), executes it with the given input, and retrieves the resulting output.

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(), json: Json = Json.Default, parentAgentId: String? = null, clock: Clock = Clock.System): Tool<AIAgentTool.AgentToolArgs, AIAgentTool.AgentToolResult>

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

Link copied to clipboard
abstract fun createManagedAgent(id: String? = null, clock: Clock = Clock.System): AIAgent<Input, Output>

Creates and registers a managed AI agent with an optional identifier and clock instance.

Link copied to clipboard
suspend override fun listActiveAgents(): List<AIAgent<Input, Output>>

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

Link copied to clipboard
open suspend override fun listAllAgents(): List<AIAgent<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
suspend override fun listFinishedAgents(): List<AIAgent<Input, Output>>

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

Link copied to clipboard
suspend override fun listInactiveAgents(): List<AIAgent<Input, Output>>

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

Link copied to clipboard
suspend override fun removeAgent(agent: AIAgent<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.