Skip to content

refactor(core): refactor toolkit and skillBox registration#377

Merged
AlbumenJ merged 6 commits intoagentscope-ai:mainfrom
fang-tech:fang-tech/refactor-toolkit-registration
Dec 29, 2025
Merged

refactor(core): refactor toolkit and skillBox registration#377
AlbumenJ merged 6 commits intoagentscope-ai:mainfrom
fang-tech:fang-tech/refactor-toolkit-registration

Conversation

@fang-tech
Copy link
Contributor

AgentScope-Java Version

1.0.4

Description

Refactor toolkit and skillBox registration
Now, for the situation where multiple tools are registered simultaneously, an error occurs when apply().
Passing in an empty value is no longer regarded as a valid call.

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

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 refactors the toolkit and skillBox registration mechanism to improve validation handling. The key change moves validation logic from individual setter methods to the apply() method using a counter-based approach, allowing multiple tool types to be set before validation occurs at application time.

  • Introduces a toolCount counter in Toolkit.ToolRegistration to track the number of non-null tool types set
  • Defers validation to the apply() method instead of checking immediately in each setter
  • Simplifies SkillBox registration by delegating validation to Toolkit

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
agentscope-core/src/main/java/io/agentscope/core/tool/Toolkit.java Refactored validation logic from setter methods to apply() using toolCount counter; removed immediate validation checks from tool(), agentTool(), mcpClient(), and subAgent() methods
agentscope-core/src/main/java/io/agentscope/core/skill/SkillBox.java Simplified apply() method to pass all tool types to toolkit registration; updated error message
agentscope-core/src/test/java/io/agentscope/core/tool/ToolkitTest.java Added comprehensive tests for multiple tool type validation and empty registration scenarios
agentscope-core/src/test/java/io/agentscope/core/skill/SkillBoxTest.java Removed redundant tests that are now covered by ToolkitTest since validation moved to Toolkit

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

@fang-tech fang-tech changed the title feat(core): refactor toolkit and skillBox registration refactor(core): refactor toolkit and skillBox registration Dec 27, 2025
@fang-tech
Copy link
Contributor Author

CI failed reason is not related to this PR

@codecov
Copy link

codecov bot commented Dec 28, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/main/java/io/agentscope/core/skill/SkillBox.java 84.61% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@fang-tech fang-tech force-pushed the fang-tech/refactor-toolkit-registration branch from fc0283f to 129fd7b Compare December 28, 2025 14:42
@AlbumenJ AlbumenJ merged commit c0c5a26 into agentscope-ai:main Dec 29, 2025
4 checks passed
JGoP-L pushed a commit to JGoP-L/agentscope-java that referenced this pull request Dec 29, 2025
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