fix(agent): sync tool group updates for existing agents#1206
Open
Alexxigang wants to merge 1 commit intoagentscope-ai:mainfrom
Open
fix(agent): sync tool group updates for existing agents#1206Alexxigang wants to merge 1 commit intoagentscope-ai:mainfrom
Alexxigang wants to merge 1 commit intoagentscope-ai:mainfrom
Conversation
Contributor
|
Hi. This PR fixes the current issue very well. However, the synchronization status is also limited to the activation and deactivation of the workgroup. For other internal states of Toolkit, such as tool list, MCP client, etc., the same issue still exists. |
2d3adf3 to
9fa6247
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Toolkit.updateToolGroups(...)state into already-builtReActAgentinstances at the start of each new invocationRoot cause
ReActAgent.Builder.build()deep-copies the providedToolkitto avoid state interference between agents. After that, later calls totoolkit.updateToolGroups(...)mutate only the caller-owned toolkit, while the existing agent keeps using its stale internal toolkit snapshot. As a result, newly activated or deactivated tool groups are not reflected for later invocations on the same agent instance.Fix
Before a fresh invocation begins, the agent now diffs the source toolkit's active groups against its internal copied toolkit and applies the required group activations/deactivations. This keeps the existing per-call toolkit isolation and avoids resetting tool-group changes during an in-flight invocation.
Validation
mvn -pl agentscope-core '-Dtest=ReActAgentToolGroupSyncTest' test -qmvn -pl agentscope-core '-Dtest=ReActAgentTest,ReActAgentToolGroupSyncTest,ToolkitTest,ToolGroupManagerTest' test -qmvn -pl agentscope-core spotless:check -q