execute

abstract suspend fun execute(context: ToolContext, args: Map<String, Any>): Any

Executes the function with the provided args, optionally utilizing the context.

Return

The tool's response, conventionally a Map<String, Any>. Non-map values are wrapped under BaseTool.RESULT_KEY. Return mapOf(ERROR_KEY to "<message>") to signal an LLM-visible error. From a long-running tool, return Unit to defer the response; see BaseTool.isLongRunning.

Parameters

context

The current ToolContext.

args

The extracted arguments provided by the LLM.