类 GracefulShutdownHook
- 所有已实现的接口:
Hook
Request registration and unregistration are handled by AgentBase.call()
via Mono.using (setup registers, cleanup unregisters), guaranteeing that
every registered request is always unregistered regardless of success, error, or cancel.
This hook is responsible for:
PreCallEvent— deduplicate input if resuming from a shutdown-interrupted session
Shutdown checkpoints — when the system is in SHUTTING_DOWN state, the agent is interrupted at these safe points (after the current phase has fully completed):
PostReasoningEvent— all LLM output chunks receivedPostActingEvent— tool execution finishedPostSummaryEvent— summary generation finished
This means during shutdown, reasoning/acting/summary phases are allowed to complete before the interrupt is issued — output tokens are not wasted. Only when the global shutdown timeout is reached will the agent be force-interrupted mid-phase (handled by GracefulShutdownManager#enforceTimeoutAndInterrupt).
-
构造器概要
构造器 -
方法概要
-
构造器详细资料
-
GracefulShutdownHook
-
-
方法详细资料
-
onEvent
从接口复制的说明:HookHandle a hook event.This method is called for all agent execution events. Use pattern matching to handle specific event types.
Modifiable Events: For events with setters, you can modify the context and the changes will affect agent execution:
PreReasoningEvent- Modify messages before LLM reasoningPostReasoningEvent- Modify reasoning resultsPreActingEvent- Modify tool parameters before executionPostActingEvent- Modify tool resultsPreCallEvent- Modify messages before agent startsPostCallEvent- Modify final agent response
Notification Events: Events without setters are read-only:
ReasoningChunkEvent- Streaming reasoning chunksActingChunkEvent- Streaming tool execution chunksErrorEvent- Errors during execution
-
priority
public int priority()从接口复制的说明:HookThe priority of this hook (lower value = higher priority).Hooks are executed in ascending priority order. Hooks with the same priority execute in their registration order.
Common Priority Ranges:
- 0-50: Critical system hooks (auth, security)
- 51-100: High priority hooks (validation, preprocessing)
- 101-500: Normal priority hooks (business logic)
- 501-1000: Low priority hooks (logging, metrics)
-