Interface ToolExecutor

All Known Implementing Classes:
NoOpToolExecutor
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ToolExecutor
Executes a tool by name and returns the result.
  • Method Details

    • execute

      ToolResult execute(String toolName, Object input, boolean approvalGranted)
      Invokes the named tool with the given input.
      Parameters:
      toolName - the tool to invoke (matches the name from the LLM's tool call)
      input - the parsed tool input (typically a Map)
      approvalGranted - true if the user has already approved execution of this tool (bypasses the approval check); false for normal execution that may return ToolResult.PendingApproval
      Returns:
      success with output, or error with message — never null
    • execute

      default ToolResult execute(String toolName, Object input, boolean approvalGranted, ToolExecutor.Call call)
      Invokes the named tool for one identified call. Decorators must forward it; the default drops the call, which is right only for executors that never run a tool that asks for confirmation.
    • resolveToolTitle

      default String resolveToolTitle(String toolCode, Object input)
      What to call one call of a tool, or null when the tool is unknown.

      The call's own input is passed because one call of a tool is not like the next: a tool that takes one record or several can only be named accurately once it knows which it was handed. The tool decides; the configured name is what it decides from, and what stands when it has nothing to add.

      The default implementation returns null. Override in decorator plugins that have access to tool metadata.

    • executionMode

      default ToolExecutor.ToolExecutionMode executionMode(String toolName)
      Execution mode for a tool. Default is ToolExecutor.ToolExecutionMode.TRANSACTIONAL; decorators override for tools whose work is an external network call that must not hold a DB connection.