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.

Methods

public abstract String invoke(String argumentsJson) throws ExceptionInvokes the tool.

Method details

invoke

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

Throws

Exception