Class AiServiceStreamingEvent.ToolCompensatedEvent
java.lang.Object
dev.langchain4j.service.AiServiceStreamingEvent.AbstractEvent
dev.langchain4j.service.AiServiceStreamingEvent.ToolCompensatedEvent
- All Implemented Interfaces:
AiServiceStreamingEvent
- Enclosing interface:
AiServiceStreamingEvent
public static final class AiServiceStreamingEvent.ToolCompensatedEvent
extends AiServiceStreamingEvent.AbstractEvent
Signals that the compensating action of a successfully-executed tool has run to roll the tool back - because
another tool failed. It carries the
ToolExecution that was rolled back (its request and original
successful result) and the CompensationReason. It is also emitted when the compensating action failed:
then compensationError() returns its error, and the effects of the tool may still be in place.
Note: this event is not emitted on cancellation. Cancelling the subscription also cancels the stream,
and the Reactive Streams contract forbids delivering further events after a cancel; a rollback triggered by
cancellation is instead observable through the ToolCompensatedEvent observability listener.
- Since:
- 1.20.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface AiServiceStreamingEvent
AiServiceStreamingEvent.AbstractEvent, AiServiceStreamingEvent.AfterToolExecutionEvent, AiServiceStreamingEvent.BeforeToolExecutionEvent, AiServiceStreamingEvent.CompleteToolCallEvent, AiServiceStreamingEvent.FinalResponseEvent, AiServiceStreamingEvent.IntermediateResponseEvent, AiServiceStreamingEvent.PartialResponseEvent, AiServiceStreamingEvent.PartialThinkingEvent, AiServiceStreamingEvent.PartialToolCallEvent, AiServiceStreamingEvent.RawEvent, AiServiceStreamingEvent.RetrievedContentsEvent, AiServiceStreamingEvent.ToolCompensatedEvent -
Constructor Summary
ConstructorsConstructorDescriptionToolCompensatedEvent(ToolExecution toolExecution, CompensationReason reason, InvocationContext invocationContext) Deprecated, for removal: This API element is subject to removal in a future version.ToolCompensatedEvent(ToolExecution toolExecution, CompensationReason reason, @Nullable Throwable compensationError, InvocationContext invocationContext) -
Method Summary
Methods inherited from class AiServiceStreamingEvent.AbstractEvent
invocationContext
-
Constructor Details
-
ToolCompensatedEvent
@Deprecated(since="1.25.0", forRemoval=true) public ToolCompensatedEvent(ToolExecution toolExecution, CompensationReason reason, InvocationContext invocationContext) Deprecated, for removal: This API element is subject to removal in a future version.UseToolCompensatedEvent(ToolExecution, CompensationReason, Throwable, InvocationContext)instead, which reports whether the compensating action failed.compensationError()of an event created with this constructor throws anUnsupportedOperationException. This constructor will be removed in a future release, no earlier than six months after the 1.25.0 release. -
ToolCompensatedEvent
public ToolCompensatedEvent(ToolExecution toolExecution, CompensationReason reason, @Nullable Throwable compensationError, InvocationContext invocationContext) - Parameters:
compensationError- the error of the compensating action, ornullwhen the tool was rolled back successfully- Since:
- 1.25.0
-
-
Method Details
-
toolExecution
-
reason
-
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 this event was created with the deprecated constructor that does not report it- Since:
- 1.25.0
-
ToolCompensatedEvent(ToolExecution, CompensationReason, Throwable, InvocationContext)instead, which reports whether the compensating action failed.