fix(core): persist tool results before middleware stop#2380
Open
March-77 wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
oss-maintainer
approved these changes
Jul 24, 2026
oss-maintainer
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Looks good.
Automated review by "github-manager-bot"
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
2.0.1-SNAPSHOT
Description
Fixes #2362.
When an
onActingmiddleware emittedRequestStopEventafter tool execution,ReActAgentreturned from the acting phase before running completed results throughnotifyPostActingHook. The precedingtool_usetherefore remained in AgentState without its matchingtool_result, even though the tool had completed successfully.This change classifies completed and suspended results before handling the stop request. For a middleware stop, completed results now pass through the normal post-acting persistence path, toolkit state is synchronized, and only then is the stop acknowledgement returned. Permission-asking behavior remains unchanged, and the stop still skips the next reasoning/model iteration.
A new end-to-end regression test executes a terminal-style tool, emits
RequestStopEventafter execution, and verifies both that the tool result is present in AgentState and that only one model call occurs.User impact
Middleware-based terminal tool flows can stop immediately without leaving orphaned tool calls or causing provider errors on the next turn.
Tests
mvn -pl agentscope-core -Dtest=ReActAgentNewLoopE2ETest test— 3 passedmvn -pl agentscope-core test— 2219 passed, 9 skippedCompatibility and risk
No public API changes. Normal acting, suspended-tool, and permission-confirmation paths retain their existing behavior. The only ordering change is that completed results are persisted before an acting middleware stop is honored.
Checklist
mvn spotless:apply