# Interface ToolHandler

public interface ToolHandler

Executor backing a `Tool`. The handler receives the raw JSON argument string the model produced and returns the JSON result to send back to the model in a `ToolResultPart`. Implementations are responsible for parsing `argumentsJson` (typically with `JSONParser`) and for serializing the result.

Pair with `Tool` via the four-argument constructor, then call `ToolCall.execute(java.util.List)` to dispatch.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `invoke(String argumentsJson)`
  Invokes the tool.

- ## Method Details

  - ### invoke

    String invoke(String argumentsJson) throws Exception
    Invokes the tool. Throw any exception to propagate it back through `ToolCall.execute(List)` -- the calling code can decide whether to surface the error to the model as a tool result or to abort the chat.
    Throws:
      `Exception`