agentscope-ai / agentscope-ai/agentscope-java

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

Đang mở
#1,306 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/core/tool bug
Ngôn ngữ chính
Java
Star
5.6k
Fork
1.3k
Merge trung bình
4 ngày 12 giờ
Pull request đã merge (30 ngày)
77

Mô tả

根因分析
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 秒,工具仍然不可用。

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.