Class ShellToolAgentHook

java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.AgentHook
com.alibaba.cloud.ai.graph.agent.hook.shelltool.ShellToolAgentHook
All Implemented Interfaces:
Hook, ToolInjection

public class ShellToolAgentHook extends AgentHook implements ToolInjection
Hook for managing ShellTool session. This hook initializes the shell session before the agent starts and cleans it up after the agent finishes.
  • Method Details

    • builder

      public static ShellToolAgentHook.Builder builder()
      Create a new builder instance.
      Returns:
      a new Builder instance
    • beforeAgent

      public CompletableFuture<Map<String,Object>> beforeAgent(OverAllState state, RunnableConfig config)
      Overrides:
      beforeAgent in class AgentHook
    • afterAgent

      public CompletableFuture<Map<String,Object>> afterAgent(OverAllState state, RunnableConfig config)
      Overrides:
      afterAgent in class AgentHook
    • getName

      public String getName()
      Specified by:
      getName in interface Hook
    • injectTool

      public void injectTool(org.springframework.ai.tool.ToolCallback toolCallback)
      Description copied from interface: ToolInjection
      Inject a tool into the hook. Only the tool matching the required tool name or type will be injected.
      Specified by:
      injectTool in interface ToolInjection
      Parameters:
      toolCallback - the tool callback to inject
    • getRequiredToolName

      public String getRequiredToolName()
      Description copied from interface: ToolInjection
      Get the required tool name that this hook needs. Return null to match by tool type instead.
      Specified by:
      getRequiredToolName in interface ToolInjection
      Returns:
      the tool name required by this hook, or null to match by type
    • getRequiredToolType

      public Class<? extends org.springframework.ai.tool.ToolCallback> getRequiredToolType()
      Description copied from interface: ToolInjection
      Get the required tool type (class) that this hook needs. Return null to match by tool name instead. If both name and type are null, the first available tool will be injected.
      Specified by:
      getRequiredToolType in interface ToolInjection
      Returns:
      the tool class type required by this hook, or null to match by name
    • getShellTool

      protected ShellTool getShellTool()
      Get the injected ShellTool instance.
      Returns:
      the ShellTool instance, or null if not injected