Class SkillsInterceptor
java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
com.alibaba.cloud.ai.graph.agent.interceptor.skills.SkillsInterceptor
- All Implemented Interfaces:
Interceptor
Interceptor for integrating Claude-style Skills into ReactAgent.
This interceptor injects skills metadata into system prompt, following progressive disclosure pattern:
- Injects lightweight skills list (name + description + path)
- Injects registry type and skill load instructions from the SkillRegistry
- LLM reads full SKILL.md content when needed using `read_skill` tool
Registration:
- Recommended: Usually registered automatically via
SkillsAgentHook, which creates and configures this interceptor along with the `read_skill` tool. - Manual: Can also be manually created and registered if you need more control over the interceptor configuration.
Usage Examples:
Automatic registration via SkillsAgentHook (recommended):
FileSystemSkillRegistry registry = FileSystemSkillRegistry.builder().build();
SkillsAgentHook hook = SkillsAgentHook.builder()
.skillRegistry(registry)
.autoReload(true)
.build();
// SkillsInterceptor is automatically created and registered by the hook
Manual registration with grouped tools (skill name → tools for dynamic injection):
Map<String, List<ToolCallback>> groupedTools = Map.of("my-skill", List.of(myTool));
SkillsInterceptor interceptor = SkillsInterceptor.builder()
.skillRegistry(registry)
.groupedTools(groupedTools)
.build();
When groupedTools is configured, this interceptor scans ModelRequest messages
for AssistantMessage with tool calls named
"read_skill". For each such call, the skill_name argument is recorded.
Tools from getGroupedTools() for those skill names are then added to the request's
dynamicToolCallbacks.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic SkillsInterceptor.Builderbuilder()getName()interceptModel(ModelRequest request, ModelCallHandler handler) Wrap a model call with custom logic.Methods inherited from class com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
getTools
-
Method Details
-
builder
-
interceptModel
Description copied from class:ModelInterceptorWrap a model call with custom logic. Implementations can: - Modify the request before calling the handler - Call the handler multiple times (retry logic) - Modify the response after handler returns - Handle exceptions and provide fallbacks- Specified by:
interceptModelin classModelInterceptor- Parameters:
request- The model requesthandler- The next handler in the chain (or base handler)- Returns:
- The model response
-
getGroupedTools
-
getName
-