Skip to content

Conversation

@Lancetnik
Copy link

@Lancetnik Lancetnik commented Oct 22, 2025

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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 mypy code reviewer agent. The changes streamline the agent's implementation by leveraging AG2's 0.10 A2A built-ins, simplifying deployment, and providing clear client examples for interaction. The overall goal is to showcase a more integrated and modern approach to building and deploying AG2 agents with A2A capabilities.

Highlights

  • Agent Example Update: The AG2 example has been significantly updated to leverage version 0.10 A2A built-ins, replacing the previous YouTube MCP agent with a new mypy code reviewer agent.
  • Simplified Agent Deployment: The Containerfile, __main__.py, agent.py, and agent_executor.py files have been removed, indicating a streamlined approach to defining and running AG2 agents, likely due to the new A2A built-ins.
  • New Mypy Code Reviewer Agent: A new a2a_python_reviewer.py file introduces an AG2 ConversableAgent that integrates mypy as a tool to perform code reviews, focusing on type validation.
  • New Client Examples: Two new client examples, cli_codegen_a2a_client.py and fastapi_codegen_a2a_client.py, have been added to demonstrate how to interact with the mypy code reviewer agent using A2A remote agents.
  • Documentation and Dependency Updates: The README.md has been thoroughly revised to reflect the new mypy agent and its setup, and pyproject.toml has been updated to ag2[mcp,openai,a2a]>=0.10.0 and mypy==1.18.2, simplifying dependencies.
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
Contributor

@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 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.

Comment on lines 41 to 45
with tempfile.NamedTemporaryFile('w', suffix='.py') as tmp:
tmp.write(code)
result = api.run([tmp.name])

return result[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This implementation has a critical bug and a potential cross-platform compatibility issue.

  1. Bug: mypy.api.run() returns a tuple of (stdout, stderr, exit_code). Mypy prints errors to stderr. By only returning result[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.
  2. Compatibility: Using with tempfile.NamedTemporaryFile() can cause file locking issues on Windows, as the file may remain open while mypy tries 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.

Suggested change
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."

Lancetnik and others added 13 commits October 22, 2025 23:52
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>
@Lancetnik
Copy link
Author

I am not sure about problems with ruff linter - locally it works fine

@Lancetnik
Copy link
Author

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?

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.

1 participant