fix(ReActAgent): preserve user chunk callback when using copied toolkit#894
Merged
LearningGp merged 7 commits intoagentscope-ai:mainfrom Mar 20, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression where user-configured Toolkit#setChunkCallback(...) was effectively overwritten by ReActAgent during tool execution, ensuring both user chunk callbacks and ActingChunkEvent hook emission work simultaneously (issue #870).
Changes:
- Split tool chunk callback handling into user vs framework-internal callbacks in
ToolExecutor. - Added
Toolkit#setInternalChunkCallback(...)soReActAgentcan emitActingChunkEventwithout overwriting user callbacks. - Preserved user chunk callbacks across
Toolkit.copy()and added a regression test covering the realReActAgentcopied-toolkit scenario.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java | Separates user/internal chunk callbacks and composes an effective callback for ToolEmitter. |
| agentscope-core/src/main/java/io/agentscope/core/tool/Toolkit.java | Adds internal chunk-callback API and preserves user chunk callback during copy(). |
| agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java | Registers an internal chunk callback (instead of overwriting the user callback) to emit ActingChunkEvent. |
| agentscope-core/src/test/java/io/agentscope/core/tool/ToolEmitterIntegrationTest.java | Adds integration regression test verifying both user callback and ActingChunkEvent receive tool-emitted chunks under ReActAgent. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
LearningGp
requested changes
Mar 18, 2026
agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java
Outdated
Show resolved
Hide resolved
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.
AgentScope-Java Version
1.0.10-SNAPSHOT
Description
Fixes #870.
Previously, when a user configured a chunk callback via
Toolkit#setChunkCallback(...)and then passed that toolkit intoReActAgent.builder().toolkit(toolkit).build(), the callback could be overwritten by the internal callback registered byReActAgentduring tool execution.This PR separates user-defined chunk callbacks from framework-internal chunk callbacks so both can work together:
Toolkit.copy()ActingChunkEventemission inReActAgentToolEmitterIntegrationTestHow to test
mvn -pl agentscope-core -Dtest=ToolEmitterIntegrationTest test