fix(react): continue after empty model responses#2355
Open
Zbhbb wants to merge 7 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the ReActAgent loop so that when the model produces an unusable response (empty stream / empty accumulated message / thinking-only / blank text), the agent continues the bounded ReAct loop to obtain a usable final assistant message, and adds regression tests for these edge cases.
Changes:
- Continue the ReAct iteration when a reasoning round accumulates no final message (e.g., empty stream / blank text that results in no accumulated content).
- Continue to the next iteration when the model returns thinking-only or blank/whitespace-only text (while persisting thinking context).
- Add regression tests covering empty stream, empty text, thinking-only, and max-iteration summary behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java | Updates the ReAct loop to continue iterations after unusable model responses and adds a helper to detect “no usable response” cases. |
| agentscope-core/src/test/java/io/agentscope/core/agent/ReActAgentNewLoopReplyTest.java | Adds regression tests for empty-stream, empty-text, thinking-only, and max-iteration summary paths. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
When a model returns an empty stream or only blank/whitespace text, the ReAct loop currently ends before it can produce a final response. Continue the existing bounded loop for those genuinely empty responses while preserving thinking-only completion, tool execution, middleware-stop, and max-iteration summary behavior.
This is distinct from #1508: that change made empty result streams complete; this change continues the existing bounded ReAct loop so the model can produce a usable response.
Changes
Test Plan
Checklist