Class SkillsAgentHook.Builder
java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.skills.SkillsAgentHook.Builder
- Enclosing class:
- SkillsAgentHook
Builder for creating SkillsAgentHook instances.
Required:
- skillRegistry: must be provided - use FileSystemSkillRegistry.builder() to create one
Optional:
- autoReload: defaults to
false- skills are loaded once during initialization - groupedTools: map from skill name to list of tools; passed to SkillsInterceptor so that when the
LLM calls
read_skillfor a skill, those tools are added to the request's dynamicToolCallbacks
Example Usage:
// Create a FileSystemSkillRegistry first
FileSystemSkillRegistry registry = FileSystemSkillRegistry.builder()
.userSkillsDirectory("~/saa/skills")
.projectSkillsDirectory("./skills")
.build();
// Then create the hook with the registry
SkillsAgentHook hook = SkillsAgentHook.builder()
.skillRegistry(registry)
.autoReload(true)
.build();
// Use a shared registry
FileSystemSkillRegistry sharedRegistry = FileSystemSkillRegistry.builder().build();
SkillsAgentHook hook1 = SkillsAgentHook.builder()
.skillRegistry(sharedRegistry)
.build();
SkillsAgentHook hook2 = SkillsAgentHook.builder()
.skillRegistry(sharedRegistry)
.build();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionautoReload(boolean autoReload) Sets whether to automatically reload skills in beforeAgent.build()Builds the SkillsAgentHook instance with the configured parameters.groupedTools(Map<String, List<org.springframework.ai.tool.ToolCallback>> groupedTools) Sets grouped tools: map from skill name to list of tools for that skill.skillRegistry(SkillRegistry skillRegistry) Sets the SkillRegistry instance.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
skillRegistry
Sets the SkillRegistry instance.Required: Must be provided. Use FileSystemSkillRegistry.builder() to create one. This is useful when you want to share a registry between multiple hooks or components.
- Parameters:
skillRegistry- the SkillRegistry to use (must not be null)- Returns:
- this builder
-
autoReload
Sets whether to automatically reload skills in beforeAgent.Optional: Defaults to
falseIf true, skills will be reloaded on each agent invocation. If false, skills are loaded once during registry initialization.
- Parameters:
autoReload- true to enable auto-reload, false to disable- Returns:
- this builder
-
groupedTools
public SkillsAgentHook.Builder groupedTools(Map<String, List<org.springframework.ai.tool.ToolCallback>> groupedTools) Sets grouped tools: map from skill name to list of tools for that skill.Optional: When set, this map is passed to SkillsInterceptor. When the LLM calls
read_skillwith a given skill_name, the corresponding tools are added to the request's dynamicToolCallbacks.- Parameters:
groupedTools- map from skill name to list of ToolCallbacks (can be null or empty)- Returns:
- this builder
-
build
Builds the SkillsAgentHook instance with the configured parameters.- Returns:
- a new SkillsAgentHook instance
- Throws:
IllegalArgumentException- if skillRegistry is not provided
-