Skip to content

fix(core): When ReactAgent reach maxIters, msg contains MAX_ITERATIONS#839

Merged
LearningGp merged 3 commits into
agentscope-ai:mainfrom
aihai:fix-ReactAgent-reach-maxIters-Msg-not-contain-MAX_ITERATIONS
Mar 4, 2026
Merged

fix(core): When ReactAgent reach maxIters, msg contains MAX_ITERATIONS#839
LearningGp merged 3 commits into
agentscope-ai:mainfrom
aihai:fix-ReactAgent-reach-maxIters-Msg-not-contain-MAX_ITERATIONS

Conversation

@aihai
Copy link
Copy Markdown
Contributor

@aihai aihai commented Feb 27, 2026

AgentScope-Java Version

1.0.10

Description

ReactAgent reach maxIters Msg not contain MAX_ITERATIONS

fixes: #777

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@aihai aihai requested a review from a team February 27, 2026 09:45
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the ReActAgent where the generated message lacked the appropriate MAX_ITERATIONS reason when the agent hit its iteration limit. The fix ensures that the agent's final message accurately reflects the cause of its termination, improving the clarity and debuggability of agent behavior. This change enhances the reliability of agent output by providing a precise reason for its completion.

Highlights

  • Bug Fix: Resolved an issue where the ReActAgent did not correctly attribute the MAX_ITERATIONS reason to the final message when its maximum iteration limit was reached.
  • GenerateReason Attribution: The summarizing() method in ReActAgent now explicitly sets GenerateReason.MAX_ITERATIONS on the summary message when the agent terminates due to exceeding its iteration limit.
  • Test Coverage: Added a new assertion in ReActAgentTest to verify that the GenerateReason of the final message is indeed MAX_ITERATIONS when the agent reaches its iteration cap.
Changelog
  • agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java
    • Reordered import statements for better organization.
    • Modified the summarizing method to include GenerateReason.MAX_ITERATIONS in the final message when the agent reaches its maximum iterations.
  • agentscope-core/src/test/java/io/agentscope/core/agent/ReActAgentTest.java
    • Reordered import statements, including adding GenerateReason import.
    • Added an assertion in testMaxIterations to confirm that the GenerateReason is MAX_ITERATIONS when the agent exceeds its iteration limit.
Activity
  • The author confirmed that the code has been formatted with mvn spotless:apply.
  • The author confirmed that all tests are passing (mvn test).
  • The author confirmed that Javadoc comments are complete and follow project conventions.
  • The author confirmed that related documentation has been updated.
  • The author confirmed that the code is ready for review.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug where GenerateReason.MAX_ITERATIONS was not set on the final message when a ReActAgent reaches its maximum iteration limit. The change in ReActAgent.java correctly sets this reason on the summary message. The test testMaxIterations in ReActAgentTest.java is also updated to assert this behavior, confirming the fix. The changes are correct and address the described issue. Minor import reordering has also been applied for style consistency.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@LearningGp LearningGp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LearningGp LearningGp merged commit 036615c into agentscope-ai:main Mar 4, 2026
6 checks passed
@aihai aihai deleted the fix-ReactAgent-reach-maxIters-Msg-not-contain-MAX_ITERATIONS branch March 13, 2026 09:50
iridescentpeo pushed a commit to feelshana/agentscope-java that referenced this pull request Apr 21, 2026
agentscope-ai#839)

## AgentScope-Java Version

1.0.10

## Description

ReactAgent reach maxIters Msg not contain MAX_ITERATIONS

fixes: agentscope-ai#777 

## Checklist

Please check the following items before code is ready to be reviewed.

- [x]  Code has been formatted with `mvn spotless:apply`
- [x]  All tests are passing (`mvn test`)
- [x]  Javadoc comments are complete and follow project conventions
- [x] Related documentation has been updated (e.g. links, examples,
etc.)
- [x]  Code is ready for review

---------

Co-authored-by: LearningGp <learninggp4.74@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReactAgent reach maxIters Msg not contain MAX_ITERATIONS

2 participants