Skip to content

feat: add AG2 multi-agent template with A2A protocol support#870

Closed
VasiliyRad wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
VasiliyRad:vasiliyr/03102026
Closed

feat: add AG2 multi-agent template with A2A protocol support#870
VasiliyRad wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
VasiliyRad:vasiliyr/03102026

Conversation

@VasiliyRad
Copy link
Copy Markdown

Why

Agent Starter Pack currently supports ADK and LangGraph. AG2 is one of the most commonly used AI Agent framework with a developer community of over 20k+ people and around 400k monthly downloads. Template makes it easier to deploy AG2 based agent to GCP.

Summary

  • Add new ag2 agent template with three specialized agents (architect, coder, reviewer) collaborating via AG2's DefaultPattern with StringLLMCondition handoffs
  • Each agent is exposed as an individual A2A endpoint using AG2's native A2aAgentServer
  • A POST /run endpoint triggers the full pipeline via initiate_group_chat()
  • Supports cloud_run, gke, and none deployment targets

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Mar 11, 2026

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 significantly enhances the Agent Starter Pack by integrating a new multi-agent template built on the popular AG2 framework. The core purpose is to streamline the process of deploying sophisticated AG2-powered agents to Google Cloud Platform. It establishes a robust collaborative system where distinct agents, such as an architect, coder, and reviewer, work in concert, intelligently passing tasks between them. This integration also ensures that these agents are accessible and interoperable through the A2A protocol, providing a standardized way for agents to communicate.

Highlights

  • New AG2 Multi-Agent Template: A new template was added to support the AG2 multi-agent framework, enabling easier deployment of AG2-based agents to GCP.
  • Collaborative Agent Pipeline: Implemented a three-agent pipeline consisting of an architect, coder, and reviewer, collaborating via AG2's DefaultPattern with StringLLMCondition for intelligent task handoffs.
  • A2A Protocol Support: Each specialized agent is exposed as an individual A2A endpoint using AG2's native A2aAgentServer, facilitating inter-agent communication.
  • Pipeline Execution Endpoint: A POST /run endpoint was introduced to trigger the entire multi-agent pipeline, simplifying the initiation of complex workflows.
  • Flexible Deployment Targets: The AG2 template supports deployment to cloud_run, gke, and none environments, offering versatility for different infrastructure needs.
Changelog
  • agent_starter_pack/agents/ag2/.template/templateconfig.yaml
    • Added configuration for the new AG2 template, including required dependencies and supported deployment targets.
  • agent_starter_pack/agents/ag2/README.md
    • Added a comprehensive README file detailing the AG2 multi-agent system, its architecture, key features, A2A validation, and instructions for running the full pipeline.
  • agent_starter_pack/agents/ag2/app/init.py
    • Added module initialization to expose the AG2 agents and orchestration pattern for import.
  • agent_starter_pack/agents/ag2/app/agent.py
    • Added definitions for the architect, coder, and reviewer ConversableAgent instances, configured their LLM-based handoff routing using StringLLMCondition, and set up the DefaultPattern for multi-agent orchestration.
  • agent_starter_pack/agents/ag2/notebooks/evaluating_ag2_agent.ipynb
    • Added a Jupyter notebook demonstrating how to evaluate the AG2 multi-agent pipeline's response quality and coherence using Vertex AI Gen AI Evaluation.
  • agent_starter_pack/agents/ag2/tests/integration/test_agent.py
    • Added integration tests to verify the functionality of the individual AG2 architect agent and the complete multi-agent pipeline.
  • agent_starter_pack/cli/utils/template.py
    • Updated the template utility to include 'ag2' as a recognized and prioritized agent framework when listing available agents.
  • agent_starter_pack/deployment_targets/cloud_run/python/{{cookiecutter.agent_directory}}/fast_api_app.py
    • Modified the FastAPI application to conditionally integrate AG2 agents, exposing them as A2A endpoints and adding a dedicated /run endpoint for pipeline execution when the AG2 template is selected for Cloud Run deployments.
  • agent_starter_pack/deployment_targets/gke/python/{{cookiecutter.agent_directory}}/fast_api_app.py
    • Modified the FastAPI application to conditionally integrate AG2 agents, exposing them as A2A endpoints and adding a dedicated /run endpoint for pipeline execution when the AG2 template is selected for GKE deployments.
Activity
  • No human activity (comments, reviews, or approvals) was detected on this pull request.
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
Copy Markdown
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 introduces a new ag2 agent template, which is a valuable addition supporting multi-agent collaboration with the A2A protocol, including agent definitions, A2A server setup, tests, and documentation. However, a critical Denial of Service (DoS) vulnerability has been identified in the /run endpoint of the FastAPI application templates for both cloud_run and gke deployment targets. The max_rounds parameter, which controls conversation depth, is not validated against an upper bound, potentially allowing an attacker to trigger long-running processes that consume excessive LLM tokens and server resources. It is strongly recommended to enforce a reasonable limit on this parameter. Additionally, there is a high-severity issue regarding an incorrect telemetry setup that will cause problems for the ag2 agent, and a medium-severity suggestion to improve the new /run API endpoint by defining a Pydantic response model to enhance API documentation and validation.

@marklysze
Copy link
Copy Markdown

@elia-secchi here's the PR referenced in our email correspondence

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.

3 participants