AIAgentService

AIAgentService is a core interface for managing AI agents. The service allows creation, removal, and management of AI agents and provides functionalities to list agents based on their statuses.f

A single instance of AIAgentService manages one kind of uniform AI Agents serving same purpose and solving same type of user task. It's useful to create, manage, and track progress of running agents solving similar user tasks in parallel.

Parameters

Input

Type parameter for the input data for the agents.

Output

Type parameter for the output data generated by the agents.

Inheritors

Types

Link copied to clipboard
object Companion

Companion object that provides factory methods for creating instances of GraphAIAgentService with various configurations.

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
abstract suspend fun agentById(id: String): AIAgent<Input, Output>?

Retrieves an AI agent based on its unique identifier.

Link copied to clipboard
open suspend fun closeAll()

Closes all AI agents currently managed by the service.

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

Creates a new instance of an AI agent with the specified parameters.

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 suspend fun listActiveAgents(): List<AIAgent<Input, Output>>

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

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

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

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

Retrieves a list of AI agents that have completed their tasks and are marked as finished.

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

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

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

Removes the specified AI agent from the service.

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

Removes an AI agent based on its unique identifier.