Class ModelHook

java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.ModelHook
All Implemented Interfaces:
Hook, Prioritized
Direct Known Subclasses:
HumanInTheLoopHook, InterruptionHook, ModelCallLimitHook, ToolCallLimitHook

public abstract class ModelHook extends Object implements Hook
  • Constructor Details

    • ModelHook

      public ModelHook()
  • Method Details

    • beforeModel

      public CompletableFuture<Map<String,Object>> beforeModel(OverAllState state, RunnableConfig config)
    • afterModel

      public CompletableFuture<Map<String,Object>> afterModel(OverAllState state, RunnableConfig config)
    • setAgentName

      public void setAgentName(String agentName)
      Description copied from interface: Hook
      Sets the name of the agent that owns this hook. This is typically called by the framework during agent initialization.
      Specified by:
      setAgentName in interface Hook
      Parameters:
      agentName - the agent name, must not be null
    • getAgentName

      public String getAgentName()
      Description copied from interface: Hook
      Gets the name of the agent that owns this hook.
      Specified by:
      getAgentName in interface Hook
      Returns:
      the agent name, or null if not set
    • getAgent

      public ReactAgent getAgent()
      Description copied from interface: Hook
      Gets the ReactAgent instance that owns this hook. This allows hooks to access the agent's state and configuration.
      Specified by:
      getAgent in interface Hook
      Returns:
      the ReactAgent instance, or null if not set
    • setAgent

      public void setAgent(ReactAgent agent)
      Description copied from interface: Hook
      Sets the ReactAgent instance that owns this hook. This is typically called by the framework during agent initialization.
      Specified by:
      setAgent in interface Hook
      Parameters:
      agent - the ReactAgent instance, 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
      Returns:
      the order value (smaller values indicate higher priority)