Interface TerminalEvent

All Superinterfaces:
JobEvent, LifecycleEvent
All Known Subinterfaces:
FailureEvent, SuccessEvent
All Known Implementing Classes:
AbstractTerminalEvent, DependencyFailureEvent, JobCancelled, JobCompletedEvent, JobFailedEvent, JobTimedOut

public sealed interface TerminalEvent extends LifecycleEvent permits AbstractTerminalEvent<R>, SuccessEvent, FailureEvent
Sealed interface for events representing a job's final state.

Permitted subtypes form a closed hierarchy:

All concrete implementations are final. User code cannot create custom terminal events - only the platform fires these. The defaults below are what a terminal event outside AbstractTerminalEvent answers: no responses, no metadata, timing read off the snapshot, the event's message as the error message, "Unknown" as the error type, and the cause taken from FailureEvent.getError() on a failure and empty otherwise.

Distinct from WorkflowTerminationEvent, which is a UI signal for workflow-scoped observers and does not extend this interface.

Since:
0.1 (2025-09-15)
Author:
Andrey Santrosyan
See Also:
  • Method Details

    • getLlmResponses

      default List<LLMResponse<?>> getLlmResponses()
      Gets the LLM responses made during job execution.
      Returns:
      list of LLM responses, may be empty but never null
    • getMetadata

      default Map<String,Object> getMetadata()
      Gets the job execution metadata (wait times, costs, etc.).
      Returns:
      metadata map, may be empty but never null
    • getStartTime

      default Instant getStartTime()
      Gets the start time of the job.
      Returns:
      start time, or null if not started
    • getCompletionTime

      default Instant getCompletionTime()
      Gets the completion time of the job.
      Returns:
      completion time
    • getDuration

      default Duration getDuration()
      Gets the duration of the job execution.
      Returns:
      duration
    • getErrorMessage

      default String getErrorMessage()
      Gets the error message if this is a failure event.
      Returns:
      error message
    • getErrorType

      default String getErrorType()
      Gets the error type if this is a failure event.
      Returns:
      error type
    • getCause

      default Optional<Throwable> getCause()
      Gets the cause if this is a failure event.
      Returns:
      optional cause