agentscope-ai / agentscope-ai/agentscope-java

[Bug]:工具组动态激活后not available

未关闭
#1,306 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area/core/tool bug
主要语言
Java
星标
5.6k
派生
1.3k
平均合并
4 天 12 小时
30 天内合并 PR
77

描述

根因分析
ToolGroup.active 字段没有 volatile

// ToolGroup.class (反编译)
public class ToolGroup {
private boolean active; // ← 非 volatile!

public boolean isActive() {
return this.active; // 普通读取
}

public void setActive(boolean active) {
this.active = active; // 普通写入
}
}
activeGroups 列表不是线程安全的

// ToolGroupManager.class (反编译)
private java.util.List activeGroups; // ← 普通 ArrayList!
执行时序

线程 boundedElastic-2 (13:14:42.630):
updateToolGroups → toolGroup.setActive(true) // 普通写
updateToolGroups → activeGroups.add("core_connector") // ArrayList 写
日志: "active status set to: true"

线程 boundedElastic-4 (13:14:45.438):
isActiveGroup("core_connector")
→ toolGroups.get("core_connector") // ConcurrentHashMap 读 ✓
→ toolGroup.isActive() // 普通读 active 字段 ✗ 读到旧值 false!
→ 返回 false
→ isActiveTool("jira_search_issues") 返回 false
→ ToolExecutor: Unauthorized!
ToolGroup.active 是普通 boolean 字段,没有 volatile 修饰,跨线程写不可见。 updateToolGroups 在 boundedElastic-2 上写入 true,但 isActiveGroup 在 boundedElastic-4 上读到的仍是初始值 false。

这就是为什么激活了、迭代了 3 轮、等了 20 秒,工具仍然不可用。

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。