AIAgentTool

class AIAgentTool<Input, Output>(agentService: AIAgentService<Input, Output, *>, agentName: String, agentDescription: String, inputDescription: String? = null, inputType: TypeToken, outputType: TypeToken, parentAgentId: String? = null) : Tool<AIAgentTool.AgentToolInput<Input>, AIAgentTool.AgentToolResult<Output>> (source)

AIAgentTool is a generic tool that wraps an AI agent to facilitate integration with the context of a tool execution framework. It enables the serialization, deserialization, and execution of an AI agent's operations.

Parameters

agentService

The AI agent service to create the agent.

agentName

A unique name for the agent.

agentDescription

A brief description of the agent's functionality. If not specified for a primitive input type (ex: String, Int, ...), an empty input description will be sent to LLM. Does not have any effect for non-primitive Input type with @LLMDescription annotations.

inputType

Type token representing input type.

outputType

Type token representing output type.

parentAgentId

Optional ID of the parent AI agent. Tool agent IDs will be generated as "parentAgentId."

Type Parameters

Input

The type of input expected by the AI agent.

Output

The type of output produced by the AI agent.

Constructors

Link copied to clipboard
constructor(agentService: AIAgentService<Input, Output, *>, agentName: String, agentDescription: String, inputDescription: String? = null, inputType: TypeToken, outputType: TypeToken, parentAgentId: String? = null)
constructor(agentService: AIAgentService<Input, Output, *>, agentName: String, agentDescription: String, inputDescription: String, inputSerializer: KSerializer<Input>, outputSerializer: KSerializer<Output>, parentAgentId: String? = null)

Types

Link copied to clipboard
data class AgentToolInput<Input>(val input: Input)

Represents the input for AIAgent used as Tool (see AIAgent.asTool)

Link copied to clipboard
data class AgentToolResult<Output>(val successful: Boolean, val errorMessage: String? = null, val result: Output? = null)

Represents the result of executing an agent tool operation.

Properties

Link copied to clipboard
val argsType: TypeToken
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val resultType: TypeToken

Functions

Link copied to clipboard
open fun decodeArgs(rawArgs: JSONObject, serializer: JSONSerializer): AIAgentTool.AgentToolInput<Input>
Link copied to clipboard
open override fun decodeResult(rawResult: JSONElement, serializer: JSONSerializer): AIAgentTool.AgentToolResult<Output>
Link copied to clipboard
open fun encodeArgs(args: AIAgentTool.AgentToolInput<Input>, serializer: JSONSerializer): JSONObject
Link copied to clipboard
fun encodeArgsToString(args: AIAgentTool.AgentToolInput<Input>, serializer: JSONSerializer): String
Link copied to clipboard
fun encodeArgsToStringUnsafe(args: Any?, serializer: JSONSerializer): String
Link copied to clipboard
fun encodeArgsUnsafe(args: Any?, serializer: JSONSerializer): JSONObject
Link copied to clipboard
open override fun encodeResult(result: AIAgentTool.AgentToolResult<Output>, serializer: JSONSerializer): JSONElement
Link copied to clipboard
open fun encodeResultToString(result: AIAgentTool.AgentToolResult<Output>, serializer: JSONSerializer): String
Link copied to clipboard
fun encodeResultToStringUnsafe(result: Any?, serializer: JSONSerializer): String
Link copied to clipboard
fun encodeResultUnsafe(result: Any?, serializer: JSONSerializer): JSONElement
Link copied to clipboard
Link copied to clipboard