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
Hook for managing ShellTool session.
This hook initializes the shell session before the agent starts and cleans it up after the agent finishes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructing ShellToolAgentHook instances. -
Method Summary
Modifier and TypeMethodDescriptionafterAgent(OverAllState state, RunnableConfig config) beforeAgent(OverAllState state, RunnableConfig config) static ShellToolAgentHook.Builderbuilder()Create a new builder instance.getName()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 ShellToolGet the injected ShellTool instance.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, 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
-
Method Details
-
builder
Create a new builder instance.- Returns:
- a new Builder instance
-
beforeAgent
- Overrides:
beforeAgentin classAgentHook
-
afterAgent
- Overrides:
afterAgentin classAgentHook
-
getName
-
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
-
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
-
getShellTool
Get the injected ShellTool instance.- Returns:
- the ShellTool instance, or null if not injected
-