feat(tool): add thread-safe whitelist management and dynamic desc#379
Merged
AlbumenJ merged 3 commits intoagentscope-ai:mainfrom Dec 28, 2025
Merged
Conversation
…ion for allowedlist
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes the ShellCommandTool by migrating from annotation-based tool definitions to the AgentTool interface pattern, while also introducing thread-safe whitelist management capabilities and dynamic description generation.
Key changes include:
- Refactored from
@Tool/@ToolParamannotations to implementing theAgentToolinterface with explicit method implementations - Enhanced whitelist management with thread-safe operations using
ConcurrentHashMap.newKeySet() - Added new public API methods for dynamic whitelist manipulation:
addAllowedCommand(),removeAllowedCommand(),clearAllowedCommands(), andisCommandAllowed()
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| agentscope-core/src/main/java/io/agentscope/core/tool/coding/ShellCommandTool.java | Implements AgentTool interface, replaces HashSet with ConcurrentHashMap for thread-safe whitelist, adds defensive copying in constructor, implements getName/getDescription/getParameters/callAsync methods, and adds new whitelist management API |
| agentscope-core/src/test/java/io/agentscope/core/tool/coding/ShellCommandToolTest.java | Adds comprehensive test coverage for whitelist management operations, thread safety scenarios, AgentTool interface implementation, and updates existing test to use new addAllowedCommand() method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agentscope-core/src/main/java/io/agentscope/core/tool/coding/ShellCommandTool.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/tool/coding/ShellCommandTool.java
Outdated
Show resolved
Hide resolved
agentscope-core/src/test/java/io/agentscope/core/tool/coding/ShellCommandToolTest.java
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/tool/coding/ShellCommandTool.java
Show resolved
Hide resolved
agentscope-core/src/main/java/io/agentscope/core/tool/coding/ShellCommandTool.java
Show resolved
Hide resolved
8c99831 to
073badf
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
AlbumenJ
approved these changes
Dec 28, 2025
JGoP-L
pushed a commit
to JGoP-L/agentscope-java
that referenced
this pull request
Dec 29, 2025
…entscope-ai#379) ## AgentScope-Java Version 1.0.4 ## Description Add a list of allowed commands to the description sent to LLM. This helps to reduce the occurrence of LLM running commands that are not allowed. Although it incurs an increase in the consumption of one-time tokens, it can reduce the number of tool invocations, which is a more token-consuming behavior. At the same time, make the modification of the allowedCommand set thread-safe. ## Checklist Please check the following items before code is ready to be reviewed. - [x] Code has been formatted with `mvn spotless:apply` - [x] All tests are passing (`mvn test`) - [x] Javadoc comments are complete and follow project conventions - [x] Related documentation has been updated (e.g. links, examples, etc.) - [x] Code is ready for review --------- Co-authored-by: Albumen Kevin <jhq0812@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
1.0.4
Description
Add a list of allowed commands to the description sent to LLM. This helps to reduce the occurrence of LLM running commands that are not allowed. Although it incurs an increase in the consumption of one-time tokens, it can reduce the number of tool invocations, which is a more token-consuming behavior. At the same time, make the modification of the allowedCommand set thread-safe.
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)