### Install Python Dependencies for Google A2A Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb Installs necessary Python packages including `google-genai`, `google-adk`, `a2a-sdk`, `python-dotenv`, `aiohttp`, `uvicorn`, `requests`, `mermaid-python`, and `nest-asyncio` for Google A2A development. This command uses `%pip` for notebook environments to ensure all required libraries are available. ```python %pip install --upgrade -q google-genai google-adk a2a-sdk python-dotenv aiohttp uvicorn requests mermaid-python nest-asyncio ``` -------------------------------- ### Start A2A Hello World Server Locally Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/helloworld/README.md Instructions to start the A2A Hello World agent server using the 'uv run .' command, which typically executes the main application file in the current directory. This command initiates the agent's local server. ```bash uv run . ``` -------------------------------- ### Run the Host Agent Front End Application Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/airbnb_planner_multiagent/host_agent/README.md This command executes the host agent front end application using `uv`, a fast Python package installer and runner. Ensure all dependencies are installed and the `.env` file is correctly configured before running. ```bash uv run . ``` -------------------------------- ### Start the A2A Server Example Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/birthday_planner_adk/calendar_agent/README.md This `uv` command initiates the A2A server application. It runs the main entry point of the project, making the agent accessible for interaction. ```bash uv run . ``` -------------------------------- ### Start A2A Travel Assistant Server Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/travel_planner_agent/README.md This command initiates the server for the A2A travel assistant application. It uses `uv` (likely `uvicorn` or a similar tool) to run the application, making it accessible for client interactions and demonstrating the A2A protocol. ```bash uv run . ``` -------------------------------- ### Setup AutoGen Currency Agent Environment Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/autogen/README.md These commands initialize a Python virtual environment, activate it, and install all required dependencies listed in 'requirements.txt' to prepare the AutoGen currency agent for execution. ```bash python -m venv venv source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Run Comprehensive Analysis with A2A Host Agent (Python) Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python example executes a complex, multi-step task on the Host Agent using the A2A client. The Host Agent orchestrates multiple underlying agents to find, analyze, and report on trending topics, demonstrating the full capability of the multi-agent system. ```python host_analysis = await a2a_client.create_task("http://localhost:10022", "Find the most relevant trends in the web today, choose randomly one of the top trends, and give me a complete analysis of it with quantitative data") print(host_analysis) ``` -------------------------------- ### Initialize and Start A2A Server in Go Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/go/server/README.md Demonstrates how to create a new A2A server instance, define a custom task handler, and start the server. The `taskHandler` function processes incoming tasks and updates their status. ```Go package main import ( "log" "a2a/samples/go/server" "a2a/samples/go/models" ) // Example task handler func taskHandler(task *models.Task, message *models.Message) (*models.Task, error) { // Process the task task.Status.State = "completed" return task, nil } func main() { // Create a new server instance srv := server.NewA2AServer(taskHandler, 8080, "/") // Start the server log.Fatal(srv.Start()) } ``` -------------------------------- ### Run A2A Translation Client Example Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/java/README.md Command to execute the A2A client example application using Maven, demonstrating how to interact with the A2A server for translation services. ```Bash cd client ../mvnw exec:java -Dexec.mainClass="com.google.a2a.client.A2AClientExample" ``` -------------------------------- ### Start Sample A2A Host Agent Server Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/multi_language/python_and_java_multiagent/host_agent/README.md This command initiates the sample host agent server. It utilizes 'uv', a modern Python package installer and executor, to run the current directory as a Python application, typically a web server. ```bash uv run . ``` -------------------------------- ### Install Python Dependencies with uv Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/a2a-mcp-without-framework/README.md This command uses `uv pip install` to efficiently install all necessary Python dependencies for the project. The `-e .` flag installs the package in editable mode, allowing for local development and changes to be reflected immediately. ```bash uv pip install -e . ``` -------------------------------- ### Install Node.js Dependencies for Samples Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/js/README.md This command installs all necessary Node.js packages and project dependencies defined in the 'package.json' file. Running 'npm install' ensures that all required libraries and modules are available for the JavaScript samples to function correctly. ```bash npm install ``` -------------------------------- ### Start the a2a-python SDK Server Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/a2a-mcp-without-framework/README.md This command initiates the A2A server component of the a2a-python SDK. It uses `uv run` to execute the server script, loading environment variables from the `.env` file, and making the server available on port 9999. ```bash uv run --env-file .env python -m src.no_llm_framework.server.__main__ ``` -------------------------------- ### Import Environment Configuration Modules in Python Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb Imports standard Python modules `os` and `sys`, along with `load_dotenv` from the `dotenv` library. This setup is crucial for configuring the A2A application by loading environment variables from a `.env` file, enabling flexible and secure configuration management. ```python import os import sys from dotenv import load_dotenv ``` -------------------------------- ### Run the a2a-python SDK Client Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/a2a-mcp-without-framework/README.md This command executes the A2A client, connecting to the previously started server. It sends a predefined question as an argument and processes the server's response, which will be saved to `response.xml`. ```bash uv run --env-file .env python -m src.no_llm_framework.client --question "What is A2A protocol?" ``` -------------------------------- ### Configure Google Cloud Environment Variables Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This snippet configures essential Google Cloud environment variables, including project ID and location, for use with Google Generative AI services. It also demonstrates loading variables from a `.env` file and printing the configured values to verify setup. ```python os.environ['GOOGLE_GENAI_USE_VERTEXAI'] = 'TRUE' os.environ["GOOGLE_CLOUD_PROJECT"] = ( "[your-project-id]" ) os.environ['GOOGLE_CLOUD_LOCATION'] = 'global' load_dotenv() print("Environment variables configured:") print(f"GOOGLE_GENAI_USE_VERTEXAI: {os.environ['GOOGLE_GENAI_USE_VERTEXAI']}") print(f"GOOGLE_CLOUD_PROJECT: {os.environ['GOOGLE_CLOUD_PROJECT']}") print(f"GOOGLE_CLOUD_LOCATION: {os.environ['GOOGLE_CLOUD_LOCATION']}") ``` -------------------------------- ### Example Tool Agent Git Operations Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/multi_agent/remote_agents/tool_agent/README.md Illustrative examples of natural language commands that the Tool Agent can process for Git operations, including cloning repositories and integrating with VSCode. ```Text "Clone https://github.com/kinfey/mcpdemo1" "Clone the repository and open it in VSCode" "Clone https://github.com/user/repo and open with VSCode Insiders" ``` -------------------------------- ### Setup and Run Analytics Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/analytics/README.md Instructions for navigating to the sample directory, setting up the Python environment with `uv`, configuring API keys, and running the analytics agent. Includes options for basic execution and custom host/port binding. ```Bash cd samples/python/agents/analytics ``` ```Bash echo "OPENAI_API_KEY=your_openai_key_here" > .env ``` ```Bash uv python pin 3.12 uv venv source .venv/bin/activate ``` ```Bash uv run . uv run . --host 0.0.0.0 --port 8080 ``` -------------------------------- ### Install Project Dependencies with uv Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/azurefoundryagent/README.md Installs all necessary project dependencies using the `uv` package manager, which is the recommended tool for dependency management in this project. ```bash uv sync ``` -------------------------------- ### Create A2A Server Application for ADK Agent in Python Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python function, `create_agent_a2a_server`, simplifies the setup of an A2A (Agent-to-Agent) server for any ADK agent. It configures agent capabilities and metadata via an `AgentCard`, initializes an `ADKAgentExecutor` with customizable status messages and artifact names, and integrates them into an `A2AStarletteApplication` for serving. ```python def create_agent_a2a_server( agent, name, description, skills, host="localhost", port=10020, status_message="Processing request...", artifact_name="response" ): """Create an A2A server for any ADK agent. Args: agent: The ADK agent instance name: Display name for the agent description: Agent description skills: List of AgentSkill objects host: Server host port: Server port status_message: Message shown while processing artifact_name: Name for response artifacts Returns: A2AStarletteApplication instance """ # Agent capabilities capabilities = AgentCapabilities(streaming=True) # Agent card (metadata) agent_card = AgentCard( name=name, description=description, url=f"http://{host}:{port}/", version="1.0.0", defaultInputModes=["text", "text/plain"], defaultOutputModes=["text", "text/plain"], capabilities=capabilities, skills=skills, ) # Create executor with custom parameters executor = ADKAgentExecutor( agent=agent, status_message=status_message, artifact_name=artifact_name ) request_handler = DefaultRequestHandler( agent_executor=executor, task_store=InMemoryTaskStore(), ) # Create A2A application return A2AStarletteApplication( agent_card=agent_card, http_handler=request_handler ) ``` -------------------------------- ### Run Genkit Agents with Gemini API Key Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/js/README.md These commands facilitate running the Genkit agents by first setting the Gemini API key as an environment variable, then starting a specific agent (e.g., 'coder'), and finally launching a separate command-line client to interact with the agent. This setup is crucial for testing the agent's functionality and observing its responses. ```bash export GEMINI_API_KEY= npm run agents:coder # in a separate terminal npm run a2a:cli ``` -------------------------------- ### Setting up and running the Movie Info Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/js/src/agents/movie-agent/README.md Instructions to set the required API keys for TMDB and Gemini, and then start the Movie Info Agent locally using npm. ```bash export TMDB_API_KEY= # see https://developer.themoviedb.org/docs/getting-started export GEMINI_API_KEY= npm run agents:movie-agent ``` -------------------------------- ### Start A2A Translation Server Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/java/README.md Command to start the Spring Boot-based A2A translation server using Maven Wrapper. The server will be accessible locally at http://localhost:8080, exposing various A2A protocol endpoints. ```Bash cd server ../mvnw spring-boot:run ``` -------------------------------- ### Run A2A Travel Assistant Loop Client Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/travel_planner_agent/README.md This command executes the loop client for the A2A travel assistant. The client interacts with the running server, demonstrating the agent-to-agent communication protocol and the functionality of the travel planning service. ```bash uv run loop_client.py ``` -------------------------------- ### Install Tool Agent Python Dependencies Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/multi_agent/remote_agents/tool_agent/README.md Command to install the project's Python dependencies using `uv`, a recommended dependency management tool, after navigating to the `remote_agents/tool_agent` directory. ```Bash cd remote_agents/tool_agent uv sync ``` -------------------------------- ### Run the A2A Server example with uv Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/airbnb_planner_multiagent/weather_agent/README.md Executes the A2A server application using `uv`, a development server for Python applications. This command starts the server, making the A2A functionalities available. ```bash uv run . ``` -------------------------------- ### Python: Initialize A2A Tool Client Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This line initializes an instance of the `A2AToolClient` class. This client object is essential for interacting with the Agent-to-Agent (A2A) communication framework, providing the necessary methods and functionalities for agent discovery, task creation, and overall orchestration within a multi-agent system. ```python a2a_client = A2AToolClient() ``` -------------------------------- ### Run ADK Agent with UV Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/adk_expense_reimbursement/README.md This command initiates the ADK agent using 'uv', a fast Python package installer and runner. It starts the agent as an A2A server, making it ready to receive requests from clients. ```bash uv run . ``` -------------------------------- ### Clone a2a-python SDK Repository Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/a2a-mcp-without-framework/README.md This command clones the a2a-python SDK repository from GitHub to your local machine, preparing the environment for further setup and development. Replace placeholders with the actual repository URL and desired directory name. ```bash git clone cd ``` -------------------------------- ### Run A2A Agent Example with UV Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/birthday_planner_adk/birthday_planner/README.md This command executes the main A2A agent example using `uv run`. Ensure that the Calendar Agent is already running as a prerequisite, as this agent relies on it for calendar-related functionalities. ```sh uv run . ``` -------------------------------- ### Run A2A Hello World Test Client Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/helloworld/README.md Command to execute the test client for the A2A Hello World agent. This client interacts with the running agent server to verify its functionality and communication. ```bash uv run test_client.py ``` -------------------------------- ### Start Azure AI Foundry Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/azurefoundryagent/README.md Initiates the main Azure AI Foundry agent application. This command should be run in a terminal to start the agent's services. ```bash uv run . ``` -------------------------------- ### Import A2A Server Components Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This code block lists the necessary Python imports for constructing an A2A server wrapper, which exposes ADK agents via the A2A protocol. It includes modules for agent execution, request handling, task management, and various ADK and Google GenAI services, laying the foundation for the server application. ```python import asyncio import uvicorn from a2a.server.agent_execution import AgentExecutor, RequestContext from a2a.server.apps import A2AStarletteApplication from a2a.server.events import EventQueue from a2a.server.request_handlers import DefaultRequestHandler from a2a.server.tasks import InMemoryTaskStore, TaskUpdater from a2a.types import ( AgentCapabilities, AgentCard, AgentSkill, MessageSendParams, Part, TaskState, TextPart, ) from a2a.utils import new_agent_text_message, new_task from google.adk.artifacts import InMemoryArtifactService from google.adk.memory.in_memory_memory_service import InMemoryMemoryService from google.adk.runners import Runner from google.adk.sessions import InMemorySessionService from google.genai import types ``` -------------------------------- ### Set API Key Environment Variable Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/travel_planner_agent/README.md This command demonstrates how to create a `.env` file and populate it with your API key. This method is commonly used to securely manage sensitive credentials outside of the main codebase, ensuring they are not hardcoded. ```bash echo "API_KEY=your_api_key_here" > .env ``` -------------------------------- ### Discover Remote A2A Agents with Python Client Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python snippet demonstrates how to use the `a2a_client` to add remote agent URLs and then list all discovered agents. It iterates through the discovered agents, printing their URLs, names, skills, and versions, verifying successful agent discovery within the A2A system. ```python a2a_client.add_remote_agent("http://localhost:10020") a2a_client.add_remote_agent("http://localhost:10021") remote_agents = a2a_client.list_remote_agents() for k, v in remote_agents.items(): print(f"Remote agent url: {k}") print(f"Remote agent name: {v['name']}") print(f"Remote agent skills: {v['skills']}") print(f"Remote agent version: {v['version']}") print("----\n") ``` -------------------------------- ### Install Python Dependencies with UV Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/README.md This command uses the UV package manager to synchronize and install all required Python dependencies for the selected A2A sample project. UV is recommended for its speed and efficiency in managing project environments. ```Shell uv sync ``` -------------------------------- ### Set Up Remote Agents Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/multi_agent/README.md Configures and starts the specialized remote agents. This includes navigating to the 'playwright_agent' and 'tool_agent' directories, synchronizing their dependencies using 'uv sync', and then running each agent using 'uv run .'. ```bash # Playwright Agent cd remote_agents/playwright_agent uv sync uv run . # Tool Agent cd ../tool_agent uv sync uv run . ``` -------------------------------- ### Start HR Agent and HR API Services Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/headless_agent_auth/README.md Command to start the HR Agent and HR API services locally using the `uv` package runner. The `--prerelease=allow` flag is used to enable prerelease features. ```bash uv run --prerelease=allow . ``` -------------------------------- ### Run A2A Client to Interact with Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/semantickernel/README.md Navigate to the A2A client directory and run this command to start the client. It will connect to the Semantic Kernel agent running on the specified address, typically `http://localhost:10020`. ```bash cd samples/python/hosts/cli uv run . --agent http://localhost:10020 ``` -------------------------------- ### Install Python Dependencies with UV Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/github-agent/README.md This command uses 'uv', a fast Python package manager, to synchronize and install all required project dependencies listed in the project's configuration. This ensures that all necessary libraries are available for the A2A GitHub agent to run correctly. ```bash # Install dependencies using UV uv sync ``` -------------------------------- ### Configure Tool Agent Environment Variables Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/multi_agent/remote_agents/tool_agent/README.md Command to create a local `.env` file from the provided example template, which is used for configuring environment-specific settings for the Tool Agent. ```Bash cp .env.example .env ``` -------------------------------- ### Navigate to ADK Video Generation Sample Directory Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/veo_video_gen/README.md Instructions to change the current directory to the location of the ADK video generation sample within the cloned repository, preparing for further setup. ```Bash cd samples/python/agents/google_adk_video_generation ``` -------------------------------- ### Install Playwright MCP Server Globally Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/multi_agent/remote_agents/playwright_agent/README.md Command to globally install the Playwright Model Context Protocol (MCP) server using npm. This is a prerequisite for the Playwright Agent to function correctly. ```bash npm install -g @playwright/mcp ``` -------------------------------- ### Communicate with Trending Agent via A2A Client (Python) Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python example shows how to send a task to a specific remote A2A agent (the Trending Agent) using `a2a_client.create_task`. It queries for 'What's trending today?' and prints the response, illustrating direct communication for a specific query. ```python trending_topics = await a2a_client.create_task("http://localhost:10020", "What's trending today?") print(trending_topics) ``` -------------------------------- ### Run A2A Demo Frontend Application Source: https://github.com/google-a2a/a2a-samples/blob/main/demo/README.md Executes the `main.py` script using `uv run` to start the A2A demo frontend web application. The application will be accessible on port 12000 by default. ```bash uv run main.py ``` -------------------------------- ### Run Go A2A Server Tests Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/go/server/README.md Provides the command to execute the comprehensive test suite for the Go A2A server, which includes tests for sending, getting, and canceling tasks, as well as streaming updates and error handling. ```Bash go test ./... ``` -------------------------------- ### Start Planner Agent for A2A Samples Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/a2a_mcp/README.md This command starts the Planner Agent, implemented using LangGraph. Its role is to break down complex user requests into structured plans that the Orchestrator Agent can then execute. It uses the `planner_agent.json` card and runs on port 10102. The host and port can be changed as needed. ```bash cd samples/python/agents/a2a_mcp uv venv # (if not already done) source .venv/bin/activate # Note: Change the host and port as needed. uv run src/a2a_mcp/agents/ --agent-card agent_cards/planner_agent.json --port 10102 ``` -------------------------------- ### Run Semantic Kernel Agent on Custom Host and Port Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/semantickernel/README.md Use this command to start the Semantic Kernel agent on a specified host and port, allowing for flexible deployment configurations beyond the default settings. ```bash uv run . --host 0.0.0.0 --port 8080 ``` -------------------------------- ### Start Coder Agent Locally Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/js/src/agents/coder/README.md This command sets the Gemini API key as an environment variable and then runs the coder agent using npm. The agent will be accessible via a local HTTP endpoint. ```bash export GEMINI_API_KEY= npm run agents:coder ``` -------------------------------- ### Compile A2A Java Project with Maven Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/java/README.md Command to compile the A2A Java sample project using Maven Wrapper, ensuring all modules are built and dependencies are installed, while skipping tests for faster compilation. ```Bash cd samples/java ./mvnw clean install -DskipTests ``` -------------------------------- ### Set Up Python Environment for Marvin Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/marvin/README.md Provides commands to navigate to the sample directory, set the OpenAI API key, and initialize the Python virtual environment using `uv` for the Marvin agent. This prepares the necessary dependencies and credentials for running the agent. ```bash cd samples/python/agents/marvin ``` ```bash export OPENAI_API_KEY=your_api_key_here ``` ```bash uv venv source .venv/bin/activate uv sync ``` -------------------------------- ### Run Airbnb Agent Server Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/multi_language/python_and_java_multiagent/README.md Navigates to the `airbnb_agent` directory and starts the Airbnb agent server using `uv run .`. This command initiates the Python MCP server for the Airbnb agent, making it available for communication. ```bash cd ../airbnb_agent uv run . ``` -------------------------------- ### Define Agent Hierarchy with Google ADK Python Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This conceptual Python example demonstrates how to define a hierarchical structure for agents using the Google ADK. It shows how to instantiate `LlmAgent` and `BaseAgent` classes and assign them as `sub_agents` to a parent coordinator agent, enabling in-process multi-agent systems where all agents are tightly coupled and managed within the same application. ```python # Conceptual Example: Defining Hierarchy from google.adk.agents import LlmAgent, BaseAgent # Define individual agents greeter = LlmAgent(name="Greeter", model="gemini-2.5-pro") task_doer = BaseAgent(name="TaskExecutor") # Custom non-LLM agent # Create parent agent and assign children via sub_agents coordinator = LlmAgent( name="Coordinator", model="gemini-2.5-pro", description="I coordinate greetings and tasks.", sub_agents=[ # Assign sub_agents here greeter, task_doer ] ) ``` -------------------------------- ### Create Trending Topics ADK Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python code defines an `Agent` using the Google ADK framework, named 'trending_topics_agent'. Its instruction set guides it to search the web for current trending topics using the `google_search` tool and return the top 3 trends in a structured JSON format, including topic, description, and reason. ```python from google.adk.agents import Agent from google.adk.tools import google_search # Create the Trending Topics ADK Agent trending_agent = Agent( model="gemini-2.5-pro", name="trending_topics_agent", instruction=""" You are a social media trends analyst. Your job is to search the web for current trending topics, particularly from social platforms. When asked about trends: 1. Search for "trending topics today" or similar queries 2. Extract the top 3 trending topics 3. Return them in a JSON format Focus on current, real-time trends from the last 24 hours. You MUST return your response in the following JSON format: { "trends": [ { "topic": "Topic name", "description": "Brief description (1-2 sentences)", "reason": "Why it's trending" }, { "topic": "Topic name", "description": "Brief description (1-2 sentences)", "reason": "Why it's trending" }, { "topic": "Topic name", "description": "Brief description (1-2 sentences)", "reason": "Why it's trending" } ] } Only return the JSON object, no additional text. """, tools=[google_search], ) print("Trending Topics Agent created successfully!") ``` -------------------------------- ### Configure Playwright Agent Environment File Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/multi_agent/remote_agents/playwright_agent/README.md Command to create a `.env` file from an example template. This file is used to store environment-specific configurations and credentials for the Playwright Agent. ```bash cp .env.example .env ``` -------------------------------- ### Run Marvin Agent and A2A Client Servers Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/marvin/README.md Instructions for starting the Marvin agent server, including options for database persistence and custom host/port, and then launching the A2A client to interact with the agent. This demonstrates how to bring up both components for a full A2A interaction. ```bash MARVIN_DATABASE_URL=sqlite+aiosqlite:///test.db MARVIN_LOG_LEVEL=DEBUG uv run . ``` ```bash # uv run . --host 0.0.0.0 --port 8080 ``` ```bash cd samples/python/hosts/cli uv run . --agent http://localhost:10030 ``` -------------------------------- ### Run Airbnb Agent Server Locally Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/airbnb_planner_multiagent/README.md This command sequence navigates to the Airbnb agent's directory and starts its local server. This agent is responsible for handling Airbnb-related queries and interacting with its corresponding MCP server. ```bash cd samples/python/agents/airbnb_planner_multiagent/airbnb_agent uv run . ``` -------------------------------- ### Create A2A Server for Analyzer Agent in Python Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python function `create_analyzer_agent_server` establishes an A2A server for a 'Trend Analyzer Agent'. It leverages the `create_agent_a2a_server` wrapper, configuring the agent's name, description, and an 'analyze_trend' skill with relevant tags and examples. The server is configured with a host, port, status message, and artifact name for quantitative trend analysis. ```python def create_analyzer_agent_server(host="localhost", port=10021): """Create A2A server for Analyzer Agent using the unified wrapper.""" return create_agent_a2a_server( agent=analyzer_agent, name="Trend Analyzer Agent", description="Performs deep analysis of trends with quantitative data", skills=[ AgentSkill( id="analyze_trend", name="Analyze Trend", description="Provides quantitative analysis of a specific trend", tags=["analysis", "data", "metrics", "statistics"], examples=[ "Analyze the #ClimateChange trend", "Get metrics for the Taylor Swift trend", "Provide data analysis for AI adoption trend" ] ) ], host=host, port=port, status_message="Analyzing trend with quantitative data...", artifact_name="trend_analysis" ) ``` -------------------------------- ### Create A2A Server for Trending Agent in Python Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python function `create_trending_agent_server` sets up an A2A server for a 'Trending Topics Agent'. It utilizes a unified `create_agent_a2a_server` wrapper, defining the agent's name, description, and a 'find_trends' skill with associated tags and examples. The server listens on a specified host and port, providing a status message and artifact name for trending topics. ```python def create_trending_agent_server(host="localhost", port=10020): """Create A2A server for Trending Agent using the unified wrapper.""" return create_agent_a2a_server( agent=trending_agent, name="Trending Topics Agent", description="Searches the web for current trending topics from social media", skills=[ AgentSkill( id="find_trends", name="Find Trending Topics", description="Searches for current trending topics on social media", tags=["trends", "social media", "twitter", "current events"], examples=[ "What's trending today?", "Show me current Twitter trends", "What are people talking about on social media?" ] ) ], host=host, port=port, status_message="Searching for trending topics...", artifact_name="trending_topics" ) ``` -------------------------------- ### Interact with ADK Video Agent via CLI Client Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/veo_video_gen/README.md An example of a text prompt input to the A2A CLI client. This demonstrates how to provide a description for video generation to the agent, which will then process the request. ```Bash >> Create a short video of a hummingbird flying in slow motion near a flower. ``` -------------------------------- ### Navigate to Hello World Agent Directory Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/helloworld/README.md Changes the current working directory to the specific location of the 'helloworld' agent's source code. This step is necessary before building the agent's container image. ```bash cd samples/python/agents/helloworld ``` -------------------------------- ### Set Up Host Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/azureaifoundry_sdk/multi_agent/README.md Prepares and launches the central host agent. This involves navigating to the 'host_agent' directory, synchronizing its Python dependencies using 'uv sync', and then starting the host agent application, which typically exposes a Gradio web interface. ```bash cd host_agent uv sync uv run . ``` -------------------------------- ### Run A2A CLI Client for Agent Validation Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/helloworld/README.md Executes the A2A command-line client, instructing it to connect to the Hello World agent running on 'http://localhost:9999'. This command is used to validate the agent's functionality and connectivity. ```bash uv run . --agent http://localhost:9999 ``` -------------------------------- ### Communicate with Analyzer Agent via A2A Client (Python) Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python snippet demonstrates sending a task to the Analyzer Agent via the A2A client to get an analysis of a specific trend, 'AI in Social Media'. It showcases another instance of direct agent communication for analytical queries. ```python analysis = await a2a_client.create_task("http://localhost:10021", "Analyze the trend AI in Social Media") print(analysis) ``` -------------------------------- ### Initialize A2A Client and Send Task in Go Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/go/client/README.md Demonstrates how to initialize the A2A client, construct a task message, and send a task to an A2A agent using the Go client library. It includes basic error handling and shows how to process the JSON-RPC response to extract the task. ```go package main import ( "log" "a2a/client" "a2a/models" ) func main() { // Create a new client a2aClient := client.NewClient("http://localhost:8080") // Create a task message message := models.Message{ Role: "user", Parts: []models.Part{ { Type: stringPtr("text"), Text: stringPtr("Hello, A2A agent!"), }, }, } // Send a task response, err := a2aClient.SendTask(models.TaskSendParams{ ID: "task-1", Message: message, }) if err != nil { log.Fatalf("Failed to send task: %v", err) } // Get the task from the response task, ok := response.Result.(*models.Task) if !ok { log.Fatalf("Expected result to be a Task") } // Use the task... } ``` -------------------------------- ### Run A2A Agent Servers in Background Threads (Python) Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python code defines asynchronous and threaded helper functions (`run_server_notebook`, `run_agent_in_background`) to start A2A agent servers using `uvicorn` in the background. It demonstrates concurrent execution of multiple agents (Trending, Analyzer, Host) and includes error handling and `nest_asyncio` for Jupyter compatibility. ```python import threading import time import nest_asyncio # Apply nest_asyncio to allow nested event loops in Jupyter nest_asyncio.apply() # Global servers to keep references servers = [] async def run_server_notebook(create_agent_function, port): """Run server with proper error handling.""" try: print(f"šŸš€ Starting agent on port {port}...") app = create_agent_function() config = uvicorn.Config( app.build(), host="127.0.0.1", port=port, log_level="error", loop="asyncio" ) server = uvicorn.Server(config) servers.append(server) await server.serve() except Exception as e: print(f"Agent error: {e}") def run_agent_in_background(create_agent_function, port, name): """Run an agent server in a background thread.""" def run() -> None: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) try: # Create the coroutine inside the new event loop loop.run_until_complete(run_server_notebook(create_agent_function, port)) except Exception as e: print(f"{name} error: {e}") thread = threading.Thread(target=run, daemon=True) thread.start() return thread # Start agent servers with corrected function calls print("Starting agent servers...\n") trending_thread = run_agent_in_background(create_trending_agent_server, 10020, "Trending Agent") analyzer_thread = run_agent_in_background(create_analyzer_agent_server, 10021, "Analyzer Agent") host_thread = run_agent_in_background(create_host_agent_server, 10022, "Host Agent") # Wait for servers to start time.sleep(3) # Check if threads are alive if trending_thread.is_alive() and analyzer_thread.is_alive(): print("\nāœ… Agent servers are running!") print(" - Trending Agent: http://127.0.0.1:10020") print(" - Analyzer Agent: http://127.0.0.1:10021") print(" - Host Agent: http://127.0.0.1:10022") else: print("\nāŒ Agent servers failed to start. Check the error messages above.") ``` -------------------------------- ### Configure Environment Variables for Google API Authentication Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/birthday_planner_adk/calendar_agent/README.md This `bash` command sequence creates or appends to a `.env` file, setting the `GOOGLE_API_KEY`, `GOOGLE_CLIENT_ID`, and `GOOGLE_CLIENT_SECRET`. These variables are crucial for authenticating with Google services and the OAuth 2.0 client. ```bash echo "GOOGLE_API_KEY=your_api_key_here" > .env echo "GOOGLE_CLIENT_ID=your_client_id_here" >> .env echo "GOOGLE_CLIENT_SECRET=your_client_secret_here" >> .env ``` -------------------------------- ### Build Hello World Agent Container Image with Podman Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/helloworld/README.md Builds a container image for the Hello World A2A agent using Podman, tagging the resulting image as 'helloworld-a2a-server'. This command compiles the agent's dependencies and code into a portable container. ```bash podman build . -t helloworld-a2a-server ``` -------------------------------- ### Authenticate Google Colab Environment Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This code block provides a conditional authentication mechanism specifically for Google Colab environments. It uses `google.colab.auth.authenticate_user` to log in the user, linking the Colab session to the specified Google Cloud project. ```python if "google.colab" in sys.modules: from google.colab import auth auth.authenticate_user( project_id=os.environ['GOOGLE_CLOUD_PROJECT'] ) ``` -------------------------------- ### Clone and Set Up Python Virtual Environment for A2A GitHub Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/github-agent/README.md These commands guide you through cloning the A2A samples repository, navigating to the specific GitHub agent project directory, creating a isolated Python virtual environment using 'uv', and activating it to manage project dependencies. ```bash # Clone the repository git clone https://github.com/a2aproject/a2a-samples.git cd a2a-samples/samples/python/agents/github-agent # Create virtual environment uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate ``` -------------------------------- ### Create .env File for Airbnb Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/multi_language/python_and_java_multiagent/README.md Navigates to the `airbnb_agent` directory and copies the `.env.example` file to `.env` to prepare for environment variable configuration. This is a standard practice for setting up local development environments. ```bash cd airbnb_agent cp .env.example .env ``` -------------------------------- ### Test Authenticated Interaction with A2A Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/birthday_planner_adk/calendar_agent/README.md This command starts the CLI host and includes an `Authorization` header with a Google ID token obtained via `gcloud`. This demonstrates how to provide authentication to the agent, allowing it to reuse user authorization across sessions. ```bash uv run . --agent="http://localhost:10007" --header="Authorization=Bearer $(gcloud auth print-identity-token)" ``` -------------------------------- ### Activate Virtual Environment and Run A2A GitHub Agent Server Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/github-agent/README.md These commands first activate the previously created Python virtual environment, ensuring that the project's dependencies are correctly loaded. Subsequently, 'uv run .' starts the A2A GitHub agent server, making it ready to accept incoming requests, typically on 'http://localhost:10007'. ```bash # Activate virtual environment source .venv/bin/activate # Run the server uv run . ``` -------------------------------- ### Define A2A Host Agent Server in Python Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This Python function `create_host_agent_server` configures and returns an A2A server instance for a host agent. It specifies the agent's name, description, and a comprehensive trend analysis skill, enabling it to orchestrate other agents for insights. ```python def create_host_agent_server(host="localhost", port=10022): """Create A2A server for Host Agent using the unified wrapper.""" return create_agent_a2a_server( agent=host_agent, name="Trend Analysis Host", description="Orchestrates trend discovery and analysis using specialized agents", skills=[ AgentSkill( id="comprehensive_trend_analysis", name="Comprehensive Trend Analysis", description="Finds trending topics and provides deep analysis of the most relevant one", tags=["trends", "analysis", "orchestration", "insights"], examples=[ "Analyze current trends", "What's trending and why is it important?", "Give me a comprehensive trend report", ], ) ], host=host, port=port, status_message="Orchestrating trend analysis...", artifact_name="trend_report" ) ``` -------------------------------- ### A2A Go Client API Reference Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/go/client/README.md Comprehensive API documentation for the Go A2A client, detailing its initialization function and core methods for interacting with the Agent-to-Agent protocol, including sending, retrieving, and canceling tasks. Each entry provides the function signature, a brief description, and details on parameters and return values. ```APIDOC func NewClient(baseURL string) *Client - Description: Creates a new A2A client instance with the specified base URL. - Parameters: - baseURL (string): The base URL for the A2A service endpoint. - Returns: A pointer to a new Client instance. func (c *Client) SendTask(params models.TaskSendParams) (*models.JSONRPCResponse, error) - Description: Sends a new task to the A2A agent. - Parameters: - params (models.TaskSendParams): A struct containing the parameters for the task to be sent, including its ID and message content. - Returns: A pointer to a models.JSONRPCResponse containing the task result or an error, and an error object if the operation failed. func (c *Client) GetTask(params models.TaskQueryParams) (*models.JSONRPCResponse, error) - Description: Retrieves the current status of a task from the A2A agent. - Parameters: - params (models.TaskQueryParams): A struct containing parameters to query the task status, typically including the task ID. - Returns: A pointer to a models.JSONRPCResponse containing the task status or an error, and an error object if the operation failed. func (c *Client) CancelTask(params models.TaskIDParams) (*models.JSONRPCResponse, error) - Description: Requests the A2A agent to cancel a specific task. - Parameters: - params (models.TaskIDParams): A struct containing parameters to identify the task to be canceled, typically its ID. - Returns: A pointer to a models.JSONRPCResponse confirming the cancellation or an error, and an error object if the operation failed. ``` -------------------------------- ### Run Hello World Agent Container Image with Port Mapping Source: https://github.com/google-a2a/a2a-samples/blob/main/samples/python/agents/helloworld/README.md Executes the previously built 'helloworld-a2a-server' container image. It maps port 9999 from the container to port 9999 on the host machine, making the agent accessible externally. ```bash podman run -p 9999:9999 helloworld-a2a-server ``` -------------------------------- ### Create Trend Analyzer ADK Agent Source: https://github.com/google-a2a/a2a-samples/blob/main/notebooks/a2a_quickstart.ipynb This snippet creates another Google ADK `Agent`, the 'trend_analyzer_agent', designed for in-depth analysis of trending topics. It leverages the `google_search` tool to find and prioritize quantitative data such as engagement metrics, growth rates, and geographic distribution, providing data-driven insights. ```python from google.adk.agents import Agent from google.adk.tools import google_search # Create the Trend Analyzer ADK Agent analyzer_agent = Agent( model="gemini-2.5-pro", name="trend_analyzer_agent", instruction=""" You are a data analyst specializing in trend analysis. When given a trending topic, perform deep research to find quantitative data and insights. For each trend you analyze: 1. Search for statistics, numbers, and metrics related to the trend 2. Look for: - Engagement metrics (views, shares, mentions) - Growth rates and timeline - Geographic distribution - Related hashtags or keywords 3. Provide concrete numbers and data points Keep it somehow concise Always prioritize quantitative information over qualitative descriptions. """, tools=[google_search], ) print("Trend Analyzer Agent created successfully!") ```