Package com.tnsai.agents.interrupt
Interface InterruptEvent
- All Known Implementing Classes:
InterruptEvent.BudgetInterrupt,InterruptEvent.ErrorInterrupt,InterruptEvent.ExternalInterrupt,InterruptEvent.TimeoutInterrupt,InterruptEvent.UserInterrupt
public sealed interface InterruptEvent
permits InterruptEvent.UserInterrupt, InterruptEvent.TimeoutInterrupt, InterruptEvent.BudgetInterrupt, InterruptEvent.ErrorInterrupt, InterruptEvent.ExternalInterrupt
Sealed hierarchy of interrupt events for agent execution control.
Interrupt events allow graceful stopping, pausing, and resuming of agent execution with different triggers.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordBudget interrupt when token/cost limits are hit.static final recordError interrupt for recoverable errors.static final recordExternal system interrupt (e.g., shutdown signal, orchestrator command).static final recordTimeout interrupt when execution exceeds time limit.static final recordUser-initiated interrupt (e.g., cancel button, Ctrl+C). -
Method Summary
Modifier and TypeMethodDescriptionCreates a budget interrupt.Creates an error interrupt.Creates an external interrupt.booleanReturns true if the agent can be resumed after this interrupt.reason()Gets the reason for the interrupt.booleanReturns true if the agent should checkpoint its state.timeout(long elapsedMillis, long limitMillis) Creates a timeout interrupt.Gets the timestamp when the interrupt was triggered.static InterruptEvent.UserInterruptCreates a user interrupt with the given reason.
-
Method Details
-
reason
String reason()Gets the reason for the interrupt. -
timestamp
Instant timestamp()Gets the timestamp when the interrupt was triggered. -
shouldCheckpoint
boolean shouldCheckpoint()Returns true if the agent should checkpoint its state. -
isResumable
boolean isResumable()Returns true if the agent can be resumed after this interrupt. -
user
Creates a user interrupt with the given reason. -
timeout
Creates a timeout interrupt. -
budget
Creates a budget interrupt. -
error
Creates an error interrupt. -
external
Creates an external interrupt.
-