Class ToolCall
A tool/function invocation produced by the model. The id round-
trips the call back to a ToolResultPart so the provider can
match the result to the original request. argumentsJson is the
raw JSON string the model produced -- parse it with
JSONParser if you need the structured fields.
Use execute(List) to dispatch to the matching Tool handler
from the request's tool list. See the Tool class javadoc for
the full pattern.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFinds theToolwhose name matches this call and invokes itsToolHandlerwith this call'sargumentsJson.Looks up the matchingToolwithout invoking it.getId()getName()
-
Constructor Details
-
ToolCall
-
-
Method Details
-
getId
-
getName
-
getArgumentsJson
-
execute
Finds the
Toolwhose name matches this call and invokes itsToolHandlerwith this call'sargumentsJson. Returns the JSON result the handler produced. Apps typically wrap that in aChatMessage.toolResult(String, String)and append it to the conversation before the next chat turn.Throws
IllegalArgumentExceptionwhen no tool intoolshas a matching name, orIllegalStateExceptionwhen the matching tool has no handler registered.- Throws:
Exception
-
findTool
-