GraphAIAgentService

class GraphAIAgentService<Input, Output>(val promptExecutor: PromptExecutor, val agentConfig: AIAgentConfig, val strategy: AIAgentGraphStrategy<Input, Output>, inputType: TypeToken, outputType: TypeToken, val toolRegistry: ToolRegistry, val installFeatures: GraphAIAgent.FeatureContext.() -> Unit) : AIAgentServiceBase<Input, Output, GraphAIAgent<Input, Output>> (source)

A service class for managing graph-based AI agents, responsible for orchestrating the behavior and execution of agents within a configurable graph-based strategy.

This class extends AIAgentServiceBase and provides an implementation for creating AI agents that follow a graph-based approach. It leverages a strategy pattern defined by AIAgentGraphStrategy to handle input and output transformations.

The GraphAIAgentService is marked with the InternalAgentsApi annotation, indicating that it is intended for internal use within agent-related implementations and not guaranteed for backward compatibility.

Parameters

promptExecutor

An instance of PromptExecutor, responsible for executing prompts using language models and handling responses.

Constructors

Link copied to clipboard
constructor(promptExecutor: PromptExecutor, agentConfig: AIAgentConfig, strategy: AIAgentGraphStrategy<Input, Output>, inputType: TypeToken, outputType: TypeToken, toolRegistry: ToolRegistry, installFeatures: GraphAIAgent.FeatureContext.() -> Unit)

Properties

Link copied to clipboard
open override val agentConfig: AIAgentConfig

Holds the configuration details for an AI agent.

Link copied to clipboard
Link copied to clipboard
open override val promptExecutor: PromptExecutor
Link copied to clipboard
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): GraphAIAgent<Input, Output>?

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

Link copied to clipboard
suspend override fun createAgent(id: String? = null, additionalToolRegistry: ToolRegistry = ToolRegistry.EMPTY, agentConfig: AIAgentConfig = this.agentConfig, clock: Clock = Clock.System): GraphAIAgent<Input, Output>

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

Link copied to clipboard
open suspend override 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, inputType: TypeToken = typeToken<Input>(), outputType: TypeToken = typeToken<Output>(), parentAgentId: String? = null, clock: Clock = Clock.System): Tool<AIAgentTool.AgentToolInput<Input>, AIAgentTool.AgentToolResult<Output>>
inline fun <Input, Output> AIAgentService<Input, Output, *>.createAgentTool(agentName: String, agentDescription: String, inputDescription: String? = null, inputSerializer: KSerializer<Input>, outputSerializer: KSerializer<Output>, parentAgentId: String? = null, clock: Clock = Clock.System): Tool<AIAgentTool.AgentToolInput<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? = null, additionalToolRegistry: ToolRegistry, agentConfig: AIAgentConfig, clock: Clock = Clock.System): GraphAIAgent<Input, Output>

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

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