Interface ToolCompensatedEvent
- All Superinterfaces:
AiServiceEvent
- All Known Implementing Classes:
DefaultToolCompensatedEvent
Invoked after the compensating action of a successfully-executed tool has run to roll the tool back - for example
because another tool failed, or because the invocation was cancelled. It carries the tool that was rolled back, its
original (successful) result, and the
CompensationReason. It is invoked also when the compensating action
failed: then compensationError() returns its error, and the effects of the tool may still be in place.
Like ToolExecutedEvent, it can be invoked multiple times within a single AI Service invocation.- Since:
- 1.20.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classNested classes/interfaces inherited from interface AiServiceEvent
AiServiceEvent.Builder<T> -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder instance for constructing aToolCompensatedEvent.default @Nullable ThrowableReturns the error of the compensating action, when it failed: the exception the compensating method threw, or the error its returned asynchronous result (for example aCompletableFuture) completed with.default Class<ToolCompensatedEvent> Retrieves the class type of the event, representing the specific category of the AI Service invocation event.reason()Returns why the tool was compensated.request()Gets theToolExecutionRequestof the tool that was compensated.Returns the contents of the compensated tool's original (successful) result.Returns the original (successful) result of the compensated tool 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 theToolExecutionRequestof the tool that was compensated. -
resultText
String resultText()Returns the original (successful) result of the compensated tool as a plain text string.- 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 compensated tool's original (successful) result.- Returns:
- the list of
Contentelements, nevernull. - Since:
- 1.20.0
-
reason
CompensationReason reason()Returns why the tool was compensated. -
compensationError
Returns the error of the compensating action, when it failed: the exception the compensating method threw, or the error its returned asynchronous result (for example aCompletableFuture) completed with. When this is notnull, the tool could not be rolled back, and its effects may still be in place.- Returns:
- the error of the compensating action, or
nullwhen the tool was rolled back successfully. - Throws:
UnsupportedOperationException- if the integration that created this event does not report it. Events built withbuilder()always report it.- Since:
- 1.25.0
-
builder
Creates a new builder instance for constructing aToolCompensatedEvent. -
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
-