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

public class ReturnDirectModelHook extends MessagesModelHook
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.
  • Constructor Details

    • ReturnDirectModelHook

      public ReturnDirectModelHook()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Hook
      Gets 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: Prioritized
      Returns the order value for this object.

      The order value determines the priority of this object when sorted with other Prioritized objects. 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:
      getOrder in interface Prioritized
      Overrides:
      getOrder in class MessagesModelHook
      Returns:
      the order value (smaller values indicate higher priority)
    • canJumpTo

      public List<JumpTo> canJumpTo()
      Description copied from interface: Hook
      Gets 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:

      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:
      beforeModel in class MessagesModelHook