executeTool

open suspend override fun executeTool(toolCall: MessagePart.Tool.Call): ReceivedToolResult(source)

Executes a tool call and returns its result.

Return

A result corresponding to the executed tool call. The result includes details such as the tool name, identifier, response content, and associated metadata.

Parameters

toolCall

A tool call messages to be executed. A message contains details about the tool, its identifier, the request content, and associated metadata.


open suspend override fun executeTool(toolCall: MessagePart.Tool.Call, metadata: ToolCallMetadata): ReceivedToolResult(source)

Executes a tool call with caller-supplied metadata and returns its result.

metadata is an additive side channel that travels alongside the call (e.g. a trace span id, a correlation id); it is not embedded in MessagePart.Tool.Call and is not serialized to the LLM.

The default implementation delegates to the single-argument executeTool overload and discards metadata, so existing environment implementations remain source-compatible. A custom environment that overrides only that single-argument overload inherits this default and silently drops any metadata supplied here; override this overload to propagate metadata to ai.koog.agents.core.tools.Tool.execute.

Return

A result corresponding to the executed tool call.

Parameters

toolCall

The tool call to execute.

metadata

Caller- and feature-contributed per-call context.