类 PendingToolRecoveryHook
- 所有已实现的接口:
Hook
ToolResultBlocks before the agent processes new input.
When tool execution fails, times out, or is interrupted, tool call states may remain in
memory without corresponding results. This hook detects such orphaned pending tool calls at
PreCallEvent time and patches them with synthetic error results, allowing the agent
to continue processing instead of crashing with IllegalStateException.
This hook is registered by default in ReActAgent.Builder. Users can disable it
via ReActAgent.Builder.enablePendingToolRecovery(boolean) if they prefer to handle
pending tool calls manually (e.g., through HITL mechanisms).
Behavior:
- Only activates when the agent is a
ReActAgent - Only patches when pending tool calls exist AND user input does not contain
ToolResultBlocks (i.e., user is not providing results themselves) - Generated error results are added to memory as TOOL-role messages
- 另请参阅:
-
构造器概要
构造器 -
方法概要
-
构造器详细资料
-
PendingToolRecoveryHook
public PendingToolRecoveryHook()
-
-
方法详细资料
-
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)
-