Class ReturnDirectModelHook
java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.messages.MessagesModelHook
com.alibaba.cloud.ai.graph.agent.hook.returndirect.ReturnDirectModelHook
- All Implemented Interfaces:
Hook,Prioritized
MessagesModelHook that checks for FINISH_REASON in ToolResponseMessage metadata.
If found, generates an AssistantMessage and jumps to END node.
This hook is designed to execute first among all hooks.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.alibaba.cloud.ai.graph.agent.hook.messages.MessagesModelHook
MessagesModelHook.AfterModelAction, MessagesModelHook.BeforeModelAction -
Field Summary
Fields inherited from interface com.alibaba.cloud.ai.graph.agent.Prioritized
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbeforeModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config) Gets the list of allowed jump destinations for this hook.getName()Gets the unique name of this hook.intgetOrder()Returns the order value for this object.Methods inherited from class com.alibaba.cloud.ai.graph.agent.hook.messages.MessagesModelHook
afterModel, afterModelAction, beforeModelAction, getAgent, getAgentName, setAgent, setAgentNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.alibaba.cloud.ai.graph.agent.hook.Hook
getHookPositions, getKeyStrategys, getModelInterceptors, getToolInterceptors, getTools
-
Constructor Details
-
ReturnDirectModelHook
public ReturnDirectModelHook()
-
-
Method Details
-
getName
Description copied from interface:HookGets the unique name of this hook. The name is used to identify the hook in the execution graph.- Returns:
- the hook name, must not be null
-
getOrder
public int getOrder()Description copied from interface:PrioritizedReturns the order value for this object.The order value determines the priority of this object when sorted with other
Prioritizedobjects. Objects with smaller order values will be sorted before objects with larger order values (ascending order).For example:
- An object with order 1 will be placed before an object with order 5
- An object with order 10 will be placed before an object with order 20
- Specified by:
getOrderin interfacePrioritized- Overrides:
getOrderin classMessagesModelHook- Returns:
- the order value (smaller values indicate higher priority)
-
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)
- Returns:
- list of allowed jump destinations, empty list by default
- See Also:
-
beforeModel
public AgentCommand beforeModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config) - Overrides:
beforeModelin classMessagesModelHook
-