Interface ToolExecutedEvent
- All Superinterfaces:
AiServiceEvent
- All Known Implementing Classes:
DefaultToolExecutedEvent
Invoked after the tool is executed.
It is important to note that this can be invoked multiple times within a single AI Service invocation.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface AiServiceEvent
AiServiceEvent.Builder<T> -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder instance for constructing aToolExecutedEvent.default Class<ToolExecutedEvent> Retrieves the class type of the event, representing the specific category of the AI Service invocation event.default booleanisError()Returns whether the tool execution failed, for example because the tool threw an exception and the error was sent to the LLM.request()Gets theToolExecutionRequestthat initiated the tool execution.Returns the contents of the tool execution result.Returns the tool execution result as a plain text string.Creates a new builder instance initialized with the properties of thisAiServiceEvent.Methods inherited from interface AiServiceEvent
invocationContext
-
Method Details
-
request
ToolExecutionRequest request()Gets theToolExecutionRequestthat initiated the tool execution. -
resultText
String resultText()Returns the tool execution result as a plain text string. This is a convenience method for when the result is known to be a singleTextContent.- Returns:
- the text of the single
TextContentelement. - Throws:
IllegalStateException- if the result contains non-text or multiple content elements. UseresultContents()instead.
-
resultContents
Returns the contents of the tool execution result.- Returns:
- the list of
Contentelements, nevernull. - Since:
- 1.13.0
-
isError
Returns whether the tool execution failed, for example because the tool threw an exception and the error was sent to the LLM. It is alsotruewhen the tool error failed the AI Service invocation (for example withToolExecutionErrorHandler.failInvocation()): then the result is the error text, which was not sent to the LLM, and anAiServiceErrorEventfollows. AI Services created withAiServicesalways report it. Integrations that create their own events should report it too: code that reads events reflectively, for example a JSON serializer that serializes this event or anAiServiceInvocationSummaryEventcontaining it, fails withUnsupportedOperationExceptionwhen it is not reported.- Returns:
trueif the tool execution failed,falseif it succeeded- Throws:
UnsupportedOperationException- if the integration that created this event does not report it- Since:
- 1.23.0
-
builder
Creates a new builder instance for constructing aToolExecutedEvent. -
eventClass
Description copied from interface:AiServiceEventRetrieves the class type of the event, representing the specific category of the AI Service invocation event.- Specified by:
eventClassin interfaceAiServiceEvent
-
toBuilder
Description copied from interface:AiServiceEventCreates a new builder instance initialized with the properties of thisAiServiceEvent. This allows modification of the existing properties and reconstruction of the event.- Specified by:
toBuilderin interfaceAiServiceEvent
-