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
  • Constructor Details

  • Method Details

    • toolExecution

      public ToolExecution toolExecution()
    • reason

      public CompensationReason reason()
    • compensationError

      public @Nullable Throwable 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 a CompletableFuture) completed with. When this is not null, the tool could not be rolled back, and its effects may still be in place.
      Returns:
      the error of the compensating action, or null when 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