Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix base agent post_run#684

Merged
rainsonGain merged 3 commits intomainfrom
fix/team_stop
Jan 5, 2026
Merged

Fix base agent post_run#684
rainsonGain merged 3 commits intomainfrom
fix/team_stop

Conversation

Copy link
Collaborator

rainsonGain commented Jan 5, 2026

team stop check improve;

team stop check improve;
Copy link
Contributor

gemini-code-assist bot commented Jan 5, 2026

Summary of Changes

Hello @rainsonGain, 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 primarily focuses on refining agent behavior, task execution, and inter-agent communication within the system. It addresses several areas, including more robust configuration handling, safer access to task configurations, and a more flexible approach to synchronous and asynchronous policy execution. Additionally, it improves the logic for determining when a team task should stop and enhances the clarity of task failure messages, contributing to a more stable and informative agent framework.

Highlights

  • Agent Configuration Handling: Corrected an oversight in agent initialization where ConfigDict instances were not properly assigned, ensuring consistent configuration application.
  • Robust Task Execution: Enhanced the async_run method with a null-check for task.conf, preventing potential errors during interactive task execution.
  • Synchronous/Asynchronous Policy Execution: Refactored policy and post_run methods to allow synchronous execution of their asynchronous counterparts, improving flexibility in agent behavior definition.
  • Agent Message Enrichment: The async_post_run method now automatically assigns the agent's ID to actions within a list if agent_name is missing, and wraps the result in an AgentMessage for standardized communication.
  • Improved Team Stop Check Logic: The _team_stop_check mechanism now conditionally triggers the 'finished' message based on the number of agent calls, and provides clearer error messages when the stop condition is not met or is prematurely evaluated.
  • Enhanced Task Response Messaging: Updated task failure responses to include the specific cause of the failure in the answer field, providing more informative feedback.

New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 or @gemini-code-assist . 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. -

rainsonGain changed the title post_run func fix; Fix base agent post_run Jan 5, 2026
Copy link
Contributor

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 introduces several fixes and improvements, notably in the post_run logic and team stop checks. I've found a critical issue in aworld/core/agent/base.py that will cause infinite recursion in the policy method. Additionally, there are opportunities to improve code quality by removing redundant code, replacing magic numbers with named constants, and addressing a parameter that shadows a Python built-in. The changes in aworld/runners/handler/task.py look good.

observation: The state observed from tools in the environment.
info: Extended information is used to assist the agent to decide a policy.
"""
return sync_exec(self.policy, observation, info=info, **kwargs)
Copy link
Contributor

gemini-code-assist bot Jan 5, 2026

Choose a reason for hiding this comment

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

This implementation of policy will cause infinite recursion. sync_exec(self.policy, ...) will call self.policy again, leading to a stack overflow. The intention is likely to call the async version of the method, async_policy.

Suggested change
return sync_exec(self.policy, observation, info=info, **kwargs)
return sync_exec(self.async_policy, observation, info=info, **kwargs)


async def async_post_run(
self, policy_result: OUTPUT, input: INPUT, message: Message = None
self, policy_result: OUTPUT, input: INPUT, message: Message = None
Copy link
Contributor

gemini-code-assist bot Jan 5, 2026

Choose a reason for hiding this comment

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

The parameter name input shadows the built-in Python function input(). It's recommended to use a different name, for example input_obj or observation_input, to avoid confusion. Furthermore, this parameter is not used within the function body. If it's intentionally unused, consider prefixing it with an underscore (e.g., _input_obj). This applies to the post_run method as well.

)

# must be an interactive call
if len(self.agent_calls) > 2:
Copy link
Contributor

gemini-code-assist bot Jan 5, 2026

Choose a reason for hiding this comment

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

The magic number 2 is used here and on line 409 to control the logic flow based on the number of agent calls. This makes the code harder to understand and maintain. It would be better to define this number as a named constant with a descriptive name (e.g., MIN_AGENT_CALLS_FOR_INTERACTIVE_MODE) at the class or module level to clarify its purpose.

topic=TopicType.FINISHED,
headers={"context": message.context}
)
agent = self.swarm.agents.get(action.agent_name)
Copy link
Contributor

gemini-code-assist bot Jan 5, 2026

Choose a reason for hiding this comment

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

This line re-fetches the agent, which was already fetched on line 381. This is redundant and can be removed.

rainsonGain added 2 commits January 5, 2026 18:38
rainsonGain merged commit 919d3f9 into main Jan 5, 2026
1 check passed
rainsonGain deleted the fix/team_stop branch January 5, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

gemini-code-assist[bot] gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant