Package com.tnsai.hooks.events
Record Class AgentStop
java.lang.Object
java.lang.Record
com.tnsai.hooks.events.AgentStop
- Record Components:
eventId- ULID-shaped correlation idtimestamp- when shutdown was initiatedcontext- surrounding hook contextreason- why the agent is stoppingcause- associated throwable whenreasonisStopReason.CRASHED; empty otherwise
- All Implemented Interfaces:
AgentHookEvent,HookEvent
public record AgentStop(String eventId, Instant timestamp, HookContext context, StopReason reason, Optional<Throwable> cause)
extends Record
implements AgentHookEvent
Fires when an agent is shutting down (issue #60). Use for flush-and-close:
drain telemetry batches, close MCP connections, persist session state.
reason is always populated; cause is present only
when reason is StopReason.CRASHED. Other reasons
carry an empty Optional.
Orchestrator (follow-up) fires this from a shutdown hook AND the normal stop path, with a guard so each agent instance only emits one.
- Since:
- 0.5.0 (issue #60)
-
Constructor Summary
ConstructorsConstructorDescriptionAgentStop(String eventId, Instant timestamp, HookContext context, StopReason reason, Optional<Throwable> cause) Creates an instance of aAgentStoprecord class. -
Method Summary
Modifier and TypeMethodDescriptioncause()Returns the value of thecauserecord component.context()Returns the value of thecontextrecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.Short stable string identifier of the event kind, e.g.final inthashCode()Returns a hash code value for this object.reason()Returns the value of thereasonrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
AgentStop
public AgentStop(String eventId, Instant timestamp, HookContext context, StopReason reason, Optional<Throwable> cause) Creates an instance of aAgentStoprecord class.
-
-
Method Details
-
eventType
Description copied from interface:HookEventShort stable string identifier of the event kind, e.g."PreToolUse". Default implementation derives it from the concrete record's simple class name; concrete records may override if a different naming is desirable. -
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. -
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. -
equals
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. All components in this record class are compared withObjects::equals(Object,Object). -
eventId
Returns the value of theeventIdrecord component. -
timestamp
Returns the value of thetimestamprecord component. -
context
Returns the value of thecontextrecord component. -
reason
Returns the value of thereasonrecord component.- Returns:
- the value of the
reasonrecord component
-
cause
Returns the value of thecauserecord component.- Returns:
- the value of the
causerecord component
-