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 摘要。