asTool

inline fun <Input, Output> AIAgent<Input, Output>.asTool(agentName: String, agentDescription: String, inputDescription: String? = null, inputSerializer: KSerializer<Input> = serializer(), outputSerializer: KSerializer<Output> = serializer(), json: Json = Json.Default): Tool<AIAgentTool.AgentToolArgs, AIAgentTool.AgentToolResult>(source)

Deprecated

Please use `AIAgentService.createAgentTool(...)`, instead.Converting an instance of `AIAgent` into a tool is error-prone because `AIAgent` is essentially a single-use instance,while tools can be run multiple times, and moreover - in parallel - by another `AIAgent`. That would cause an error.

Converts the current AI agent into a tool to allow using it in other agents as a tool.

Return

A special tool that wraps the agent functionality.

Parameters

agentName

Agent name that would be a tool name for this agent tool.

agentDescription

Agent description that would be a tool description for this agent tool.

inputDescription

An optional description of the agent's input. Required for primitive types only!

  • 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.

inputSerializer

Serializer to deserialize tool arguments to agent input.

outputSerializer

Serializer to serialize agent output to tool result.

json

Optional Json instance to customize de/serialization behavior.