Skip to content

Conversation

svchk12
Copy link

@svchk12 svchk12 commented Jul 14, 2025

A Beginner-Friendly Skeleton Example for A2A and ADK
While there are many excellent samples available, newcomers often find it quite challenging to get started with Agent-to-Agent (A2A) communication and the Agent Development Kit (ADK).

To address this, I've created a simple skeleton example designed for ease of use by absolute beginners. My hope is that this will help make agent development more accessible to everyone, fostering broader adoption and innovation within the A2A ecosystem.

This minimalist example aims to provide a clear and immediate starting point, demonstrating the core mechanics of agent interaction without overwhelming complexity.

@svchk12 svchk12 requested a review from a team as a code owner July 14, 2025 08:11
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.

Summary of Changes

Hello @svchk12, 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 foundational, beginner-friendly skeleton project for Agent-to-Agent (A2A) communication, leveraging the Agent Development Kit (ADK). It aims to simplify the initial setup for new developers by providing a clear, minimalist example of a microservice architecture composed of interconnected agents, complete with a gateway and specialized sub-agents.

Highlights

  • New Skeleton Project: Introduces a complete, runnable skeleton project (a2a_skeleton) demonstrating Agent-to-Agent (A2A) communication and the Agent Development Kit (ADK) concepts, designed for beginners.
  • Microservice Architecture: Implements a multi-agent system showcasing inter-agent communication, including a gateway for external requests, a generate_contents_agent for content creation, a search_agent for information retrieval, and a host_agent for agent management and routing.
  • Comprehensive Documentation: Provides detailed README.md files for the overall project and each sub-agent, covering project overview, structure, installation steps (using uv), execution instructions, and usage examples.
  • Core Agent Functionality: Demonstrates how to build and connect different types of agents (LLM-based for content generation and search, and a host agent for routing and discovery) within the A2A framework, including session management and streaming responses.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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 introduces an excellent skeleton project for A2A and ADK, which will be very helpful for beginners. The overall structure is logical and well-organized. My review identifies a few critical issues that could cause the services to crash, along with other recommendations to align the code with best practices and make it more robust and easier to understand.

raise

async def cancel(self, context: RequestContext, event_queue: EventQueue):
raise ServerError(error=UnsupportedOperationError())
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The cancel method attempts to raise ServerError, but it has not been imported. This will result in a NameError at runtime. You need to import ServerError from a2a.utils.errors.

Choose a reason for hiding this comment

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

Here's how you might modify it:

from a2a.utils.errors import ServerError

async def cancel(self, context: RequestContext, event_queue: EventQueue):
    """Cancels an ongoing operation."""
    raise ServerError(error=UnsupportedOperationError())

The reason UnsupportedOperationError is wrapped inside ServerError is to standardize error responses according to the JSON-RPC specification.

UnsupportedOperationError itself contains the code, message, and data fields that align with the JSON-RPC error format. By raising ServerError with UnsupportedOperationError as its payload, the system ensures that any specific operational error (like an unsupported action) is consistently presented to the client in a predictable and uniform JSON-RPC error structure. This centralizes error handling and simplifies how clients process various server-side issues.

)

HOST = os.getenv('HOST')
PORT = int(os.getenv('PORT'))
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Calling int(os.getenv('PORT')) is unsafe. If the PORT environment variable is not set, os.getenv('PORT') will return None, and int(None) will raise a TypeError, crashing the application on startup. You should provide a default value to os.getenv to prevent this.

Suggested change
PORT = int(os.getenv('PORT'))
PORT = int(os.getenv('PORT', '8002'))
raise

async def cancel(self, context: RequestContext, event_queue: EventQueue):
raise ServerError(error=UnsupportedOperationError())
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The cancel method attempts to raise ServerError, but it has not been imported. This will result in a NameError at runtime. You need to import ServerError from a2a.utils.errors.

)

HOST = os.getenv('HOST')
PORT = int(os.getenv('PORT'))
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Calling int(os.getenv('PORT')) is unsafe. If the PORT environment variable is not set, os.getenv('PORT') will return None, and int(None) will raise a TypeError, crashing the application on startup. You should provide a default value to os.getenv to prevent this.

Suggested change
PORT = int(os.getenv('PORT'))
PORT = int(os.getenv('PORT', '8003'))
async def send_message(request: Request):
data = await request.json()
#session_id = data.get("session_id", "default")
query = data.get("query", {})
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The default value for query is an empty dictionary ({}), but the curl example and subsequent usage expect a string. If the query field is missing from the request body, passing the empty dictionary to the agent will likely cause issues. The default value should be an empty string "" to handle missing queries gracefully.

Suggested change
query = data.get("query", {})
query = data.get("query", "")
logger.info(f"invoke 진입전 ")
async for event in self.agent.invoke(query, session_id, task.id, user_id):
event_dict = event.dict()
text = event_dict['content']['parts'][0]['text']
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Accessing nested dictionary keys like event_dict['content']['parts'][0]['text'] is fragile and can lead to KeyError or IndexError if the event structure is not what's expected. It's safer to access these values through the pydantic model attributes on the event object itself, and add checks to ensure event.content and event.content.parts are not empty.

Suggested change
text = event_dict['content']['parts'][0]['text']
text = event.content.parts[0].text if event.content and event.content.parts else ""
Comment on lines +107 to +109
except Exception as e :
raise
yield {"error": "LLM이 올바른 포맷/에이전트 이름을 반환하지 못했습니다."}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The invoke method's error handling is problematic: The except Exception as e: raise block is inside the retry loop, preventing the retry from happening. Also, the yield {"error": ...} after the loop is not a valid A2A event. Instead, you should raise a specific exception that the executor can catch and handle gracefully.

Comment on lines +44 to +45
for part in event_dict["artifact"]["parts"]:
text = part['text']
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The loop for part in event_dict["artifact"]["parts"]: overwrites the text variable in each iteration. If an artifact has multiple parts, only the text from the last part will be preserved. You should concatenate the text from all parts.

                    text=""
                    for part in event_dict["artifact"]["parts"]:
                        if part.get('text'):
                            text += part['text']
logger.info(f"invoke 진입전 ")
async for event in self.agent.invoke(query, session_id, task.id, user_id):
event_dict = event.dict()
text = event_dict['content']['parts'][0]['text']
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Accessing nested dictionary keys like event_dict['content']['parts'][0]['text'] is fragile and can lead to KeyError or IndexError if the event structure is not what's expected. It's safer to access these values through the pydantic model attributes on the event object itself, and add checks to ensure event.content and event.content.parts are not empty.

Suggested change
text = event_dict['content']['parts'][0]['text']
text = event.content.parts[0].text if event.content and event.content.parts else ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants