fix: prevent presetParameters from being overridden by tool-call input#1172
Open
JGoP-L wants to merge 4 commits intoagentscope-ai:mainfrom
Open
fix: prevent presetParameters from being overridden by tool-call input#1172JGoP-L wants to merge 4 commits intoagentscope-ai:mainfrom
JGoP-L wants to merge 4 commits intoagentscope-ai:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a security/contract bug in ToolExecutor where framework-controlled presetParameters could be overwritten by tool-call input during execution, ensuring preset values remain authoritative (e.g., API keys and other hidden parameters).
Changes:
- Adjusted tool input merge order so tool-call input is applied first and
presetParametersare applied last (take precedence). - Updated the preset-parameter precedence unit test expectation to match the intended behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java | Changes merge order so preset parameters override any same-key tool-call/caller input during execution. |
| agentscope-core/src/test/java/io/agentscope/core/tool/ToolkitTest.java | Updates testPresetParametersOverride to assert preset values win over provided input. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.12-SNAPSHOT
Description
This PR fixes an issue where
presetParameterscould be overridden by tool-call input during tool execution.Background:
presetParametersare intended for framework-controlled values such as API keys or other hidden parameters. While these fields are excluded from the tool schema shown to the LLM, the execution-time merge order inToolExecutorallowed tool-call input to overwrite preset values when the same key appeared in both places.Changes made:
ToolExecutorto merge tool-call input first and applypresetParameterslastHow to test:
mvn -pl agentscope-core -Dtest=io.agentscope.core.tool.ToolkitTest#testPresetParameters testmvn -pl agentscope-core -Dtest=io.agentscope.core.tool.ToolkitTest#testPresetParametersOverride testmvn -pl agentscope-core -Dtest=io.agentscope.core.tool.ToolkitTest testmvn -pl agentscope-core -Dtest=ToolExecutorTest testpresetParameters, the preset value winsCloses #1119
Checklist
mvn spotless:applymvn test)