fix(example): Inconsistent groupManager in ReActAgent.Builder#build due to toolkit copying#560
Merged
AlbumenJ merged 3 commits intoagentscope-ai:mainfrom Jan 16, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
问题描述: - ReActAgent.Builder#build 时会复制 toolkit 以避免状态干扰 - 如果在原始 toolkit 上调用 registerMetaTool(),meta tool 会使用原始 toolkit 的 groupManager - 但复制后的 toolkit 的 schemaProvider 使用的是新 toolkit 的 groupManager - 导致 toolGroup 激活操作的 groupManager 与 tool scheme 生成的 groupManager 不一致 修复方案: - 移除在原始 toolkit 上直接调用 registerMetaTool() 的方式 - 改为通过 Builder.enableMetaTool(true) 在 build 时在复制的 toolkit 上注册 meta tool - 确保 meta tool 和 schemaProvider 使用同一个 groupManager 实例 修改文件: - ToolGroupExample.java: 移除 toolkit.registerMetaTool() 调用,改用 .enableMetaTool(true)
69b2731 to
ff30d64
Compare
Collaborator
|
Please translate title and description into English |
AlbumenJ
approved these changes
Jan 16, 2026
Alexxigang
pushed a commit
to Alexxigang/agentscope-java
that referenced
this pull request
Jan 25, 2026
…ue to toolkit copying (agentscope-ai#560)
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.
During
ReActAgent.Builder#build, the toolkit is copied to prevent state interference. However, this leads to a mismatch ingroupManagerinstances under certain conditions:registerMetaTool()is called on the original toolkit, the meta tool holds a reference to the original toolkit'sgroupManager.schemaProvideruses the copied toolkit'sgroupManager.groupManagerused for tool group activation differs from the one used in schema generation, causing inconsistency.Fix:
registerMetaTool()on the original toolkit.Builder.enableMetaTool(true)to register the meta tool during build time on the copied toolkit.groupManagerinstance.