refactor(CodeactAgentConfig): 调整配置类结构并优化搜索工具管理#10
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request refactors the CodeactAgentConfig class structure and optimizes search tool management. The main purpose is to fix an issue where search tools could not be found during dependency injection.
Changes:
- Moved CodeactAgentConfig from
com.alibaba.assistant.agent.autoconfiguretocom.alibaba.assistant.agent.start.configpackage - Changed search tool injection from
List<SearchCodeactTool>toSearchCodeactToolFactorypattern - Enhanced UnifiedSearchCodeactTool to support both source type names and provider names
- Updated model name from "qwen3-coder-plus" to "aliyun-qwen3-coder-plus"
- Added null safety check for replyCodeactTools
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| CodeactAgentConfig.java | Relocated to correct package, switched to factory pattern for search tools, updated model name, added null safety |
| UnifiedSearchCodeactTool.java | Enhanced to support provider name-based search in addition to source type search, updated parameter descriptions |
Comments suppressed due to low confidence (1)
assistant-agent-start/src/main/java/com/alibaba/assistant/agent/start/config/CodeactAgentConfig.java:367
- The inline comment mentions "使用 qwen-coder-plus 模型进行代码生成" but the actual model name has been changed to "aliyun-qwen3-coder-plus". Consider updating the comment to reflect the new model name for consistency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| List<SearchResultItem> items = provider.search(request); | ||
| allItems.addAll(items); |
There was a problem hiding this comment.
Potential NullPointerException: if provider.search(request) returns null on line 176, calling allItems.addAll(items) will throw an NPE. Consider adding a null check or ensuring search() never returns null.
| .name("sources") | ||
| .type(ParameterType.ARRAY) | ||
| .description("要搜索的数据源列表,默认搜索 project 和 knowledge") | ||
| .description("要搜索的数据源列表,支持标准类型(project, knowledge, web等)或指定Provider名称") |
There was a problem hiding this comment.
The documentation description has been updated to mention "支持标准类型(project, knowledge, web等)或指定Provider名称" which correctly reflects the new functionality. However, the example values shown as "project, knowledge, web等" don't match the actual enum values returned by getAvailableSourceNames() which uses lowercase. Consider updating the documentation to clarify the expected format.
| .description("要搜索的数据源列表,支持标准类型(project, knowledge, web等)或指定Provider名称") | |
| .description("要搜索的数据源列表,支持标准小写类型(如:project、knowledge、web 等)或指定 Provider 名称") |
| itemsProp.put("enum", getAvailableSourceNames()); | ||
| sourcesProp.put("items", itemsProp); | ||
| sourcesProp.put("description", "要搜索的数据源列表,默认搜索 project 和 knowledge"); | ||
| sourcesProp.put("description", "要搜索的数据源列表,支持标准类型或Provider名称"); |
There was a problem hiding this comment.
The documentation description mentions "支持标准类型或Provider名称" but doesn't clarify the format. The actual enum values are lowercase (from getAvailableSourceNames()), but the documentation example doesn't make this clear. Consider being more explicit about the expected format.
| sourcesProp.put("description", "要搜索的数据源列表,支持标准类型或Provider名称"); | |
| sourcesProp.put("description", | |
| "要搜索的数据源列表。每个元素为小写字符串,必须匹配 getAvailableSourceNames() 返回的标准类型名称或 Provider 名称。"); |
| // 如果没有指定,使用默认的源类型 | ||
| if (keys.isEmpty()) { | ||
| keys.add(SearchSourceType.PROJECT.name()); | ||
| keys.add(SearchSourceType.KNOWLEDGE.name()); |
There was a problem hiding this comment.
Inconsistency in default values: parseSourceKeys() returns uppercase enum names like "PROJECT" and "KNOWLEDGE" as defaults (lines 260-261), but getAvailableSourceNames() returns lowercase enum names (line 274). While this works due to the toUpperCase() call in executeUnifiedSearch, it creates an inconsistent API. Consider using lowercase in parseSourceKeys to match getAvailableSourceNames().
| // 如果没有指定,使用默认的源类型 | |
| if (keys.isEmpty()) { | |
| keys.add(SearchSourceType.PROJECT.name()); | |
| keys.add(SearchSourceType.KNOWLEDGE.name()); | |
| // 如果没有指定,使用默认的源类型(与 getAvailableSourceNames 的小写形式保持一致) | |
| if (keys.isEmpty()) { | |
| keys.add(SearchSourceType.PROJECT.name().toLowerCase()); | |
| keys.add(SearchSourceType.KNOWLEDGE.name().toLowerCase()); |
更新了缺陷报告模板的语言为中文,使其更易于中文用户理解和填写。增加了“修复方式”部分以便更好地指导用户选择合适的处理方式。
修复了在处理搜索结果时未检查 `items` 是否为空导致的潜在空指针异常问题。
修复了搜索工具无法被找到的问题