Class InterruptionHook
java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.ModelHook
com.alibaba.cloud.ai.graph.agent.hook.InterruptionHook
- All Implemented Interfaces:
AsyncNodeActionWithConfig,InterruptableAction,Hook,Prioritized,BiFunction<OverAllState,RunnableConfig, CompletableFuture<Map<String, Object>>>
public class InterruptionHook
extends ModelHook
implements AsyncNodeActionWithConfig, InterruptableAction
Hook that supports interruption and feedback mechanism.
This hook checks for interruption requests and handles feedback messages.
Example:
InterruptionHook hook = InterruptionHook.builder().build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.alibaba.cloud.ai.graph.action.AsyncNodeActionWithConfig
AsyncNodeActionWithConfig.InterruptableAsyncNodeActionWrapper -
Field Summary
FieldsFields inherited from interface com.alibaba.cloud.ai.graph.agent.Prioritized
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Method Summary
Modifier and TypeMethodDescriptionapply(OverAllState state, RunnableConfig config) static InterruptionHook.Builderbuilder()Gets the list of allowed jump destinations for this hook.Gets the key strategies for state management.getName()Gets the unique name of this hook.interrupt(String nodeId, OverAllState state, RunnableConfig config) Methods inherited from class com.alibaba.cloud.ai.graph.agent.hook.ModelHook
afterModel, beforeModel, getAgent, getAgentName, getOrder, setAgent, setAgentNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.function.BiFunction
andThenMethods inherited from interface com.alibaba.cloud.ai.graph.agent.hook.Hook
getHookPositions, getModelInterceptors, getToolInterceptors, getToolsMethods inherited from interface com.alibaba.cloud.ai.graph.action.InterruptableAction
interruptAfter
-
Field Details
-
INTERRUPTION_FEEDBACK_KEY
- See Also:
-
INTERRUPTION_NODE_NAME
- See Also:
-
-
Method Details
-
builder
-
apply
- Specified by:
applyin interfaceAsyncNodeActionWithConfig- Specified by:
applyin interfaceBiFunction<OverAllState,RunnableConfig, CompletableFuture<Map<String, Object>>>
-
interrupt
public Optional<InterruptionMetadata> interrupt(String nodeId, OverAllState state, RunnableConfig config) - Specified by:
interruptin interfaceInterruptableAction
-
getName
Description copied from interface:HookGets the unique name of this hook. The name is used to identify the hook in the execution graph. -
canJumpTo
Description copied from interface:HookGets the list of allowed jump destinations for this hook.Hooks can control the flow of execution by specifying where the agent can jump to after the hook executes. This allows hooks to redirect the execution flow based on their logic.
Common jump destinations include:
JumpTo.model: Jump to model nodeJumpTo.tool: Jump to tool nodeJumpTo.end: Jump to end (terminate agent)
-
getKeyStrategys
Description copied from interface:HookGets the key strategies for state management.Key strategies define how state values are merged when updating the agent's state. This allows hooks to control how their state updates interact with the agent's state.
Common strategies include:
AppendStrategy: Append to existing valuesReplaceStrategy: Replace existing values
- Specified by:
getKeyStrategysin interfaceHook- Returns:
- map of key names to their strategies, empty map by default
- See Also:
-