-
Notifications
You must be signed in to change notification settings - Fork 119
Conversation
Summary of ChangesHello @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
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 AssistThe 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
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 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
|
There was a problem hiding this 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.
aworld/core/agent/base.py
Outdated
| 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) |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
aworld/runners/handler/agent.py
Outdated
| topic=TopicType.FINISHED, | ||
| headers={"context": message.context} | ||
| ) | ||
| agent = self.swarm.agents.get(action.agent_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.