agentscope-ai / agentscope-ai/agentscope-java

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

オープン
#1,306 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
area/core/tool bug
主要言語
Java
スター
5.6k
フォーク
1.3k
平均マージ
4日 12時間
マージ済み PR(30日)
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 を短くまとめたダイジェスト。