-
Notifications
You must be signed in to change notification settings - Fork 450
feat: update AG2 example using 0.10 A2A builtins #392
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Lancetnik, 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 introduces a substantial update to the AG2 agent example, transitioning from a YouTube MCP agent to a 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
This pull request is a great simplification of the AG2 example, effectively showcasing the new A2A built-in features from version 0.10. The shift to a mypy code reviewer agent is a clear and practical demonstration. My review focuses on fixing a few typos in the documentation and code, correcting an invalid dependency version that would break installation, and addressing a critical bug in the mypy tool implementation which currently prevents it from reporting any errors.
| with tempfile.NamedTemporaryFile('w', suffix='.py') as tmp: | ||
| tmp.write(code) | ||
| result = api.run([tmp.name]) | ||
|
|
||
| return result[0] |
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 has a critical bug and a potential cross-platform compatibility issue.
- Bug:
mypy.api.run()returns a tuple of(stdout, stderr, exit_code). Mypy prints errors tostderr. By only returningresult[0](stdout), any type errors found by mypy will be ignored, and the agent will not receive the feedback it needs to correct the code. - Compatibility: Using
with tempfile.NamedTemporaryFile()can cause file locking issues on Windows, as the file may remain open whilemypytries to access it.
The suggested change fixes both issues by manually handling the temporary file's lifecycle and correctly returning stderr when errors are detected.
| with tempfile.NamedTemporaryFile('w', suffix='.py') as tmp: | |
| tmp.write(code) | |
| result = api.run([tmp.name]) | |
| return result[0] | |
| # Use delete=False and manual cleanup to avoid file locking issues on Windows. | |
| fp = tempfile.NamedTemporaryFile('w', suffix='.py', delete=False) | |
| try: | |
| fp.write(code) | |
| fp.close() # Close the file so mypy can open it. | |
| stdout, stderr, exit_status = api.run([fp.name]) | |
| finally: | |
| os.remove(fp.name) | |
| # Mypy reports errors on stderr. Return stderr if errors exist, otherwise return stdout. | |
| if exit_status != 0: | |
| return stderr | |
| return stdout or "No issues found." |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
I am not sure about problems with ruff linter - locally it works fine |
|
Hi @holtskinner! Can we merge this one, please? But I am not sure - should we replace the previous sample (there are some posts and articles linked to it) or should we just create a new one? |
Update regarding the AG2 0.10 release: I removed the old example and replaced it with built-in A2A support. Now we have a single A2A-hosted agent that can be used as a stateless reviewer in various Python-codegen workflows. We also have two alternative workflows that interact with the remote agent using the A2A protocol. I hope rhe current demo clearly demonstrates the benefits and possibilities of A2A.