callTool

Executes the specified tool with the given arguments and returns the result within a SafeTool.Result wrapper.

Return

a SafeTool.Result containing the tool's execution result of type TResult.

Parameters

tool

the tool to be executed.

args

the arguments required to execute the tool.

Type Parameters

TArgs

the type of arguments required by the tool.

TResult

the type of result returned by the tool, implementing ToolResult.


suspend fun <TArgs> AIAgentLLMWriteSession.callTool(toolName: String, args: TArgs): SafeTool.Result<out Any?>(source)

Executes a tool by its name with the provided arguments.

Return

A SafeTool.Result containing the result of the tool execution, which is a subtype of ai.koog.agents.core.tools.ToolResult.

Parameters

toolName

The name of the tool to be executed.

args

The arguments required to execute the tool.


Executes a tool operation based on the provided tool class and arguments.

Return

A result wrapper containing either the successful result of the tool's execution or an error.

Parameters

toolClass

The class of the tool to be executed.

args

The arguments to be passed to the tool for its execution.

Type Parameters

TArgs

The type of arguments required by the tool.

TResult

The type of result produced by the tool.


inline suspend fun <ToolT : Tool<Any?, Any?>> AIAgentLLMWriteSession.callTool(args: Any?): SafeTool.Result<out Any?>(source)

Invokes a tool of the specified type with the provided arguments.

Return

A SafeTool.Result containing the outcome of the tool's execution, which may be of any type that extends ToolResult.

Parameters

args

The input arguments required for the tool execution.

inline suspend fun <TResult> AIAgentLLMWriteSession.callTool(toolFunction: KFunction<TResult>, vararg args: Any?): SafeTool.Result<TResult>(source)

Invokes a specified tool function within the AI Agent's write session context.

Return

The result of executing the specified tool function.

Parameters

toolFunction

The tool function to be executed.

args

The arguments to pass to the tool function.

Throws

If the tool corresponding to the given function is not found in the tool registry.