Record Class RunEndEvent

java.lang.Object
java.lang.Record
com.tnsai.events.RunEndEvent
Record Components:
eventId - unique identifier for this event
timestamp - when the event occurred
runId - the run identifier (matches RunStartEvent)
status - the completion status (COMPLETED, FAILED, CANCELLED)
result - the final result (for successful runs)
durationMs - total execution duration in milliseconds
All Implemented Interfaces:
TnsAIEvent

public record RunEndEvent(String eventId, Instant timestamp, String runId, RunEndEvent.RunStatus status, String result, long durationMs) extends Record implements TnsAIEvent
Event indicating that an agent run has completed.

RunEndEvent is emitted when a chat/run execution finishes, either successfully or with an error.

This event is paired with RunStartEvent.

  • Constructor Details

    • RunEndEvent

      public RunEndEvent(String eventId, Instant timestamp, String runId, RunEndEvent.RunStatus status, String result, long durationMs)
      Creates an instance of a RunEndEvent record class.
      Parameters:
      eventId - the value for the eventId record component
      timestamp - the value for the timestamp record component
      runId - the value for the runId record component
      status - the value for the status record component
      result - the value for the result record component
      durationMs - the value for the durationMs record component
  • Method Details

    • completed

      public static RunEndEvent completed(String runId, String result, long durationMs)
      Creates a successful run end event.
      Parameters:
      runId - the run identifier
      result - the final result
      durationMs - execution duration
      Returns:
      new RunEndEvent
    • failed

      public static RunEndEvent failed(String runId, long durationMs)
      Creates a failed run end event.
      Parameters:
      runId - the run identifier
      durationMs - execution duration
      Returns:
      new RunEndEvent
    • cancelled

      public static RunEndEvent cancelled(String runId, long durationMs)
      Creates a cancelled run end event.
      Parameters:
      runId - the run identifier
      durationMs - execution duration
      Returns:
      new RunEndEvent
    • timedOut

      public static RunEndEvent timedOut(String runId, long durationMs)
      Creates a timed out run end event.
      Parameters:
      runId - the run identifier
      durationMs - execution duration
      Returns:
      new RunEndEvent
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • eventId

      public String eventId()
      Returns the value of the eventId record component.
      Specified by:
      eventId in interface TnsAIEvent
      Returns:
      the value of the eventId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface TnsAIEvent
      Returns:
      the value of the timestamp record component
    • runId

      public String runId()
      Returns the value of the runId record component.
      Returns:
      the value of the runId record component
    • status

      public RunEndEvent.RunStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • result

      public String result()
      Returns the value of the result record component.
      Returns:
      the value of the result record component
    • durationMs

      public long durationMs()
      Returns the value of the durationMs record component.
      Returns:
      the value of the durationMs record component