fix(react): continue after empty model responses - #2355
Conversation
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! |
oss-maintainer
left a comment
There was a problem hiding this comment.
LGTM. Looks good.
Automated review by "github-manager-bot"
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds resilience to ReActAgent's reasoning loop when the model returns empty or blank-only responses. The agent retries by advancing to the next iteration, bounded by maxIters. The stop-requested path is correctly refactored to not trigger the retry. Good test coverage.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds resilience to ReActAgent's reasoning loop when the model returns empty or blank-only responses. The agent retries by advancing to the next iteration, bounded by maxIters. The stop-requested path is correctly refactored to not trigger the retry. Good test coverage.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds resilience to ReActAgent's reasoning loop when the model returns empty or blank-only responses. The agent retries by advancing to the next iteration, bounded by maxIters. The stop-requested path is correctly refactored to not trigger the retry. Good test coverage.
7407965 to
dac175a
Compare
b433483 to
2f0ac3b
Compare
2f0ac3b to
4e33938
Compare
|
已查看失败 job 的完整日志。该次失败不是 ReActAgent 逻辑或 #2355 新增测试断言失败,而是 agentscope-harness 中既有的 JsonSessionDefaultLocationTest 在 JUnit @tempdir 清理阶段发生竞态:perUserPartitioning_viaSharedAgentRoutedByRuntimeContext 结束时报告 Failed to close extension context,根因是 Failed to delete temp directory,抑制异常为 DirectoryNotEmptyException。#2355 的改动仅涉及 agentscope-core/ReActAgent.java 及其两个测试文件,没有修改 agentscope-harness;本地执行 mvn -q -pl agentscope-harness -am test 已成功。 |
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