-
Notifications
You must be signed in to change notification settings - Fork 232
处理创建智能体时,没有工具列表的问题 #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
loveTsong
merged 1 commit into
ModelEngine-Group:main
from
wuayee:main-create_agents_no_tools
Oct 14, 2025
Merged
处理创建智能体时,没有工具列表的问题 #488
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import modelengine.jade.store.service.PluginToolService; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
@@ -68,7 +69,7 @@ void beforeAll() { | |
| this.aippModelCenter, | ||
| this.toolService, | ||
| this.localeService, | ||
| this.appRepository); | ||
| this.appRepository, "system"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 单测已增加 |
||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -135,6 +136,81 @@ void shouldOkWhenSelectTools() { | |
| "UNIQUENAME3"); | ||
| } | ||
|
|
||
| @Test | ||
| void testMerge_tool1IsNull_returnsTools2() { | ||
| ListResult<PluginToolData> tools2 = new ListResult<>(List.of(new PluginToolData()), 1); | ||
| ListResult<PluginToolData> result = this.invokeMerge(null, tools2); | ||
| Assertions.assertSame(tools2, result); | ||
| } | ||
|
|
||
| /** | ||
| * 测试当 tool1 的 count 为 0 时是否正确返回 tools2 | ||
| */ | ||
| @Test | ||
| void testMerge_tool1IsEmpty_returnsTools2() { | ||
| ListResult<PluginToolData> tool1 = new ListResult<>(new ArrayList<>(), 0); | ||
| ListResult<PluginToolData> tools2 = new ListResult<>(List.of(new PluginToolData()), 1); | ||
| ListResult<PluginToolData> result = this.invokeMerge(tool1, tools2); | ||
| Assertions.assertSame(tools2, result); | ||
| } | ||
|
|
||
| /** | ||
| * 测试当 tools2 为 null 时是否正确返回 tool1 | ||
| */ | ||
| @Test | ||
| void testMerge_tools2IsNull_returnsTool1() { | ||
| ListResult<PluginToolData> tool1 = new ListResult<>(List.of(new PluginToolData()), 1); | ||
| ListResult<PluginToolData> result = invokeMerge(tool1, null); | ||
| Assertions.assertSame(tool1, result); | ||
| } | ||
|
|
||
| /** | ||
| * 测试当 tools2 的 count 为 0 时是否正确返回 tool1 | ||
| */ | ||
| @Test | ||
| void testMerge_tools2IsEmpty_returnsTool1() { | ||
| ListResult<PluginToolData> tool1 = new ListResult<>(List.of(new PluginToolData()), 1); | ||
| ListResult<PluginToolData> tools2 = new ListResult<>(new ArrayList<>(), 0); | ||
| ListResult<PluginToolData> result = invokeMerge(tool1, tools2); | ||
| Assertions.assertSame(tool1, result); | ||
| } | ||
|
|
||
| /** | ||
| * 测试正常情况下两个列表能否成功合并 | ||
| */ | ||
| @Test | ||
| void testMerge_bothValid_mergeCorrectly() { | ||
| PluginToolData data1 = new PluginToolData(); | ||
| PluginToolData data2 = new PluginToolData(); | ||
| ListResult<PluginToolData> tool1 = new ListResult<>(List.of(data1), 1); | ||
| ListResult<PluginToolData> tools2 = new ListResult<>(List.of(data2), 1); | ||
|
|
||
| ListResult<PluginToolData> result = invokeMerge(tool1, tools2); | ||
|
|
||
| Assertions.assertNotNull(result); | ||
| Assertions.assertEquals(2, result.getCount()); | ||
| Assertions.assertTrue(result.getData().contains(data1)); | ||
| Assertions.assertTrue(result.getData().contains(data2)); | ||
| } | ||
|
|
||
| /** | ||
| * 利用反射机制调用私有方法 merge | ||
| * | ||
| * @param tool1 第一个 ListResult 参数 | ||
| * @param tools2 第二个 ListResult 参数 | ||
| * @return 合并后的 ListResult 结果 | ||
| */ | ||
| private ListResult<PluginToolData> invokeMerge(ListResult<PluginToolData> tool1, ListResult<PluginToolData> tools2) { | ||
| try { | ||
| var method = AgentInfoGenerateServiceImpl.class.getDeclaredMethod("merge", | ||
| ListResult.class, ListResult.class); | ||
| method.setAccessible(true); | ||
| return (ListResult<PluginToolData>) method.invoke(this.agentInfoGenerateService, tool1, tools2); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to invoke private method 'merge'", e); | ||
| } | ||
| } | ||
|
|
||
| @NotNull | ||
| private ModelListDto getModelListDto() { | ||
| List<ModelAccessInfo> modelAccessInfos = new ArrayList<>(); | ||
|
|
||
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.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这边调用的地方,是不同创建者创造的插件,从业务上讲不会重复,所以不需要去重