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,Prioritized
Hook for managing ShellTool2 session.
This hook initializes the shell session before the agent starts and cleans it up after the agent finishes.
Supports ShellTool2 (@Tool annotation).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructing ShellToolAgentHook instances. -
Field Summary
Fields inherited from interface com.alibaba.cloud.ai.graph.agent.Prioritized
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Method Summary
Modifier and TypeMethodDescriptionafterAgent(OverAllState state, RunnableConfig config) beforeAgent(OverAllState state, RunnableConfig config) static ShellToolAgentHook.Builderbuilder()Create a new builder instance.getName()Gets the unique name of this hook.Get the required tool name that this hook needs.Class<? extends org.springframework.ai.tool.ToolCallback>Get the required tool type (class) that this hook needs.protected ShellTool2Get the injected ShellTool2 instance.List<org.springframework.ai.tool.ToolCallback>getTools()Gets the list of tools provided by this hook.voidinjectTool(org.springframework.ai.tool.ToolCallback toolCallback) Inject a tool into the hook.Methods inherited from class com.alibaba.cloud.ai.graph.agent.hook.AgentHook
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 com.alibaba.cloud.ai.graph.agent.hook.Hook
canJumpTo, getHookPositions, getKeyStrategys, getModelInterceptors, getToolInterceptors
-
Method Details
-
builder
Create a new builder instance.- Returns:
- a new Builder instance
-
beforeAgent
- Overrides:
beforeAgentin classAgentHook
-
afterAgent
- Overrides:
afterAgentin classAgentHook
-
getName
Description copied from interface:HookGets the unique name of this hook. The name is used to identify the hook in the execution graph. -
injectTool
public void injectTool(org.springframework.ai.tool.ToolCallback toolCallback) Description copied from interface:ToolInjectionInject a tool into the hook. Only the tool matching the required tool name or type will be injected.- Specified by:
injectToolin interfaceToolInjection- Parameters:
toolCallback- the tool callback to inject
-
getTools
Description copied from interface:HookGets the list of tools provided by this hook.Tools provided by hooks will be merged with the agent's configured tools and made available for the agent to use during execution.
These tools will be registered with the agent's tool node and can be invoked by the agent during its execution.
-
getRequiredToolName
Description copied from interface:ToolInjectionGet the required tool name that this hook needs. Return null to match by tool type instead.- Specified by:
getRequiredToolNamein interfaceToolInjection- Returns:
- the tool name required by this hook, or null to match by type
-
getRequiredToolType
Description copied from interface:ToolInjectionGet 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:
getRequiredToolTypein interfaceToolInjection- Returns:
- the tool class type required by this hook, or null to match by name
-
getShellTool2
Get the injected ShellTool2 instance.- Returns:
- the ShellTool2 instance, or null if not injected
-