-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix IndexError in ParallelAgent by adding events length check #3566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @prolsen, 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 potential runtime Highlights
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
The pull request correctly fixes a potential IndexError by adding a length check before accessing events[-2]. I've also suggested a small refactoring to make the condition more concise and Pythonic using slicing and any(), which also handles edge cases gracefully.
| if events and ( | ||
| ctx.should_pause_invocation(events[-1]) | ||
| or ctx.should_pause_invocation(events[-2]) | ||
| or (len(events) >= 2 and ctx.should_pause_invocation(events[-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.
While the fix is correct, the logic to check the last two events can be simplified and made more robust using a slice and any(). This avoids manual length checks and is more idiomatic. Using [::-1] on the slice preserves the evaluation order of checking the last event first.
if any(ctx.should_pause_invocation(event) for event in events[-2:][::-1]):|
Response from ADK Triaging Agent Hello @prolsen, thank you for your contribution! Before we can merge your pull request, we need to ask you to do the following:
You can find more details in our contribution guidelines. Thank you! |
|
Hi @prolsen ,Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you! |
No description provided.