Skip to content

refactor(CodeactAgentConfig): 调整配置类结构并优化搜索工具管理#10

Merged
AQing-527 merged 4 commits intomainfrom
feature/fix_search_tools
Jan 14, 2026
Merged

refactor(CodeactAgentConfig): 调整配置类结构并优化搜索工具管理#10
AQing-527 merged 4 commits intomainfrom
feature/fix_search_tools

Conversation

@canfuu
Copy link
Collaborator

@canfuu canfuu commented Jan 14, 2026

修复了搜索工具无法被找到的问题

Copilot AI review requested due to automatic review settings January 14, 2026 05:36
Copy link

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 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.autoconfigure to com.alibaba.assistant.agent.start.config package
  • Changed search tool injection from List<SearchCodeactTool> to SearchCodeactToolFactory pattern
  • 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.

Comment on lines 176 to 177
List<SearchResultItem> items = provider.search(request);
allItems.addAll(items);
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
.name("sources")
.type(ParameterType.ARRAY)
.description("要搜索的数据源列表,默认搜索 projectknowledge")
.description("要搜索的数据源列表,支持标准类型(project, knowledge, web等)或指定Provider名称")
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
.description("要搜索的数据源列表,支持标准类型(project, knowledge, web等)或指定Provider名称")
.description("要搜索的数据源列表,支持标准小写类型(如:projectknowledge、web 等)或指定 Provider 名称")

Copilot uses AI. Check for mistakes.
itemsProp.put("enum", getAvailableSourceNames());
sourcesProp.put("items", itemsProp);
sourcesProp.put("description", "要搜索的数据源列表,默认搜索 project 和 knowledge");
sourcesProp.put("description", "要搜索的数据源列表,支持标准类型或Provider名称");
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
sourcesProp.put("description", "要搜索的数据源列表,支持标准类型或Provider名称");
sourcesProp.put("description",
"要搜索的数据源列表。每个元素为小写字符串,必须匹配 getAvailableSourceNames() 返回的标准类型名称或 Provider 名称。");

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +261
// 如果没有指定,使用默认的源类型
if (keys.isEmpty()) {
keys.add(SearchSourceType.PROJECT.name());
keys.add(SearchSourceType.KNOWLEDGE.name());
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Suggested change
// 如果没有指定,使用默认的源类型
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());

Copilot uses AI. Check for mistakes.
更新了缺陷报告模板的语言为中文,使其更易于中文用户理解和填写。增加了“修复方式”部分以便更好地指导用户选择合适的处理方式。
修复了在处理搜索结果时未检查 `items` 是否为空导致的潜在空指针异常问题。
Copy link
Collaborator

@AQing-527 AQing-527 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AQing-527 AQing-527 merged commit f4a462d into main Jan 14, 2026
1 check passed
@AQing-527 AQing-527 deleted the feature/fix_search_tools branch January 14, 2026 06:16
@canfuu canfuu restored the feature/fix_search_tools branch January 14, 2026 10:02
@canfuu canfuu deleted the feature/fix_search_tools branch January 15, 2026 02:27
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