Skip to content

fix(tool): make active tool groups concurrency-safe#1183

Open
Alexxigang wants to merge 1 commit intoagentscope-ai:mainfrom
Alexxigang:fix/thread-safe-tool-group-state
Open

fix(tool): make active tool groups concurrency-safe#1183
Alexxigang wants to merge 1 commit intoagentscope-ai:mainfrom
Alexxigang:fix/thread-safe-tool-group-state

Conversation

@Alexxigang
Copy link
Copy Markdown
Contributor

Summary

  • store active tool-group names in a concurrency-safe snapshot set instead of a plain ArrayList
  • keep ToolGroup.active aligned with setActiveGroups(...) replacements and concurrent updates
  • add regression coverage for concurrent read/write access, snapshot replacement, and copyTo(...) isolation

Why this fix

ToolGroupManager already uses concurrent maps for group and tool indexes, but �ctiveGroups remained a mutable ArrayList. In concurrent agent scenarios, activation/deactivation and snapshot reads such as getActiveGroups() / getActivatedNotes() can race, and the list can diverge from each ToolGroup's active flag. This patch makes the active-group snapshot safe for concurrent access while preserving the existing public API.

Validation

  • mvn -pl agentscope-core spotless:apply
  • mvn -pl agentscope-core '-Dtest=ToolGroupManagerTest,ToolGroupManagerConcurrencyTest,ToolkitTest,ToolGroupsE2ETest' test

Closes #1165.

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.

Bug: ToolGroupManager.activeGroups is not thread-safe, causing race conditions in concurrent agent scenarios

1 participant