Skip to content

refactor(skill): consolidate skill discovery tools into single load_skill_through_path tool#505

Merged
AlbumenJ merged 4 commits intoagentscope-ai:mainfrom
fang-tech:fang-tech/refactor-skill-discovery-tool
Jan 14, 2026
Merged

refactor(skill): consolidate skill discovery tools into single load_skill_through_path tool#505
AlbumenJ merged 4 commits intoagentscope-ai:mainfrom
fang-tech:fang-tech/refactor-skill-discovery-tool

Conversation

@fang-tech
Copy link
Contributor

AgentScope-Java Version

1.0.7-SNAPSHOT

Description

Summary

This PR refactors the skill access mechanism by consolidating three separate tools into a single unified tool, significantly reducing the tool call chain in worst-case scenarios.

Changes

Tool Consolidation

  • Merged skill_md_load_tool, skill_resources_load_tool, and get_all_resources_path_tool into a single load_skill_through_path tool
  • Extracted tool creation logic from SkillBox into new SkillToolFactory class for better separation of concerns

Prompt Structure Improvement

  • Restructured skill system prompt using XML tags (<skill>, <name>, <description>, <skill-id>) for improved LLM parsing accuracy

SkillBox API

  • Addd getAllSkillIds() method

Key Benefit: Reduced Tool Call Chain

Best-case improvement:

  • From 2 calls (list + load) → 1 call (direct load with auto-discovery on failure)
  • Reduces LLM reasoning overhead by exposing fewer tools in the schema
  • Simplifies the mental model for skill resource access

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

…e tool.

Place the Skill built-in tool into the SkilltoolFactory to create it.
Structure the skill system prompt using XML tags
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates the skill discovery mechanism by merging three separate tools (skill_md_load_tool, skill_resources_load_tool, and get_all_resources_path_tool) into a single unified load_skill_through_path tool. The refactoring extracts tool creation logic into a dedicated SkillToolFactory class and restructures the skill system prompt with XML tags for improved LLM parsing.

Changes:

  • Consolidated three skill access tools into one unified tool with automatic resource listing on failure
  • Extracted tool creation logic from SkillBox to new SkillToolFactory class
  • Restructured skill prompts using XML tags (<skill>, <name>, <description>, <skill-id>)
  • Added getAllSkillIds() method to SkillBox API

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
SkillToolFactory.java New factory class for creating the consolidated skill access tool
SkillBox.java Removed three @Tool methods and added registerSkillLoadTool() and getAllSkillIds()
AgentSkillPromptProvider.java Restructured prompt template with XML tags for better LLM parsing
ReActAgent.java Updated integration to call registerSkillLoadTool() instead of registerTool()
SkillBoxToolsTest.java Updated tests to validate the new consolidated tool behavior
SkillBoxTest.java Added tests for getAllSkillIds() method
AgentSkillPromptProviderTest.java Updated tests to validate new XML-based prompt structure
docs/en/task/agent-skill.md Updated documentation to reference new tool name and API
docs/zh/task/agent-skill.md Updated Chinese documentation to match English version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +518 to +520
toolkit.createToolGroup(
"skill-build-in-tools",
"skill build-in tools, could contain(load_skill_through_path)");
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "build-in" should be "built-in". The correct term is "built-in tools" not "build-in tools".

Copilot uses AI. Check for mistakes.
return Mono.just(ToolResultBlock.error(e.getMessage()));
}
}
// ==================== Skill Build-In Tools ====================
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "Build-In" should be "Built-In". The correct term is "Built-In Tools" not "Build-In Tools".

Copilot uses AI. Check for mistakes.
skillId));
}
return skill;
logger.info("Registered skill load tools to toolkit");
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "skill load tools" should be "skill load tool" (singular). The method registers one tool (load_skill_through_path), not multiple tools.

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +64
+ " usage instructions)\n"
+ "- 'SKILL.md': The skill's markdown documentation (name, description,"
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description text has lines 63-64 in the wrong order. Line 63 should come after line 64 to maintain proper sentence structure. The current text reads "2. Returns the requested resource content\n usage instructions)\n- 'SKILL.md': The skill's markdown documentation (name, description," which is incomplete and confusing.

Suggested change
+ " usage instructions)\n"
+ "- 'SKILL.md': The skill's markdown documentation (name, description,"
+ "- 'SKILL.md': The skill's markdown documentation (name, description,"
+ " usage instructions)\n"

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +94
+ " skill (e.g., 'SKILL.md,"
+ " references/references.md')")),
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description string for the 'path' parameter is incomplete - it ends with an opening single quote and comma without closing. The string reads "'SKILL.md," but should likely be "'SKILL.md', 'references/references.md')". This will result in a malformed parameter description for API consumers.

Suggested change
+ " skill (e.g., 'SKILL.md,"
+ " references/references.md')")),
+ " skill (e.g., 'SKILL.md',"
+ " 'references/references.md')")),

Copilot uses AI. Check for mistakes.
"type",
"string",
"description",
"The unique identifier of the" + " skill.",
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string concatenation on line 84 has an unnecessary split with "The unique identifier of the" + " skill." This should be a single string "The unique identifier of the skill." for better readability and consistency with the rest of the code.

Suggested change
"The unique identifier of the" + " skill.",
"The unique identifier of the skill.",

Copilot uses AI. Check for mistakes.
@fang-tech fang-tech closed this Jan 10, 2026
@fang-tech fang-tech reopened this Jan 10, 2026
@fang-tech
Copy link
Contributor Author

@copilot open a new pull request to apply changes based on the comments in this thread

@fang-tech fang-tech closed this Jan 10, 2026
@fang-tech fang-tech reopened this Jan 10, 2026
@codecov
Copy link

codecov bot commented Jan 10, 2026

@AlbumenJ AlbumenJ merged commit 1c303b9 into agentscope-ai:main Jan 14, 2026
4 checks passed
@fang-tech fang-tech deleted the fang-tech/refactor-skill-discovery-tool branch January 17, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants