execute

suspend fun execute(args: TArgs, serializer: JSONSerializer): SafeTool.Result<TResult>(source)

Executes the tool with the provided arguments and returns the result.

This method constructs a MessagePart.Tool.Call with the given arguments, passes it to the environment for execution, and converts the received tool result into a safe result encapsulated in a Result type.

Return

A Result containing the outcome of the tool execution, either a success or a failure.

Parameters

args

The arguments required for the tool execution.

serializer

The JSON serializer for encoding the tool arguments.


suspend fun execute(args: TArgs, serializer: JSONSerializer, metadata: ToolCallMetadata): SafeTool.Result<TResult>(source)

Executes the tool with the provided arguments and caller-supplied metadata, returning the result.

The metadata is threaded through the environment into Tool.execute as a side channel (e.g. a trace span id). When combined with metadata contributed by installed features, the caller-supplied entries take precedence on key collision.

Return

A Result containing the outcome of the tool execution.

Parameters

args

The arguments required for the tool execution.

serializer

The JSON serializer for encoding the tool arguments.

metadata

Caller-contributed per-call context.