Agent2Agent (A2A) Samples

repository·main·Indexed 23 days ago

https://github.com/a2aproject/a2a-samples

Official code samples and demonstrations for the A2A Protocol, an open standard for multi-agent interoperability. Includes a Mesop-based Demo Web App, a Helloworld agent, and language-specific implementations for Python, Go, .NET, Java, and JavaScript. Features documentation on protocol extensions such as the Secure Passport Extension v1 for trusted contextual state transfer and the Timestamp extension.

Tokens
38.7K
Snippets
84
Records
194
Agent score
82%

What's inside a2a-samples

  1. Overview of JavaScript Agents

    main

    The samples/js directory contains several specialized agents built with Genkit:

    • Movie Agent: Uses the TMDB API to search for movie information and answer questions.
    • Coder Agent: Generates full code files as artifacts.
    • Content Editor Agent: Proof-reads and polishes content. This agent is designed to be used within a multi-agent system, such as the content_creation Python sample.
  2. Overview of the A2A Client SDK

    main
    The A2A Client SDK is a pure Java library that implements the client-side functionality for the Agent-to-Agent (A2A) protocol. It allows developers to discover, communicate with, and manage tasks with A2A-compatible agents using a JSON-RPC 2.0 implementation. The SDK supports full task lifecycle management (send, query, cancel) and real-time updates via streaming.
  3. Overview of the Timestamp Extension example

    main

    The timestamp extension is a reference implementation used to demonstrate how A2A (Agent2Agent) extensions function. It provides a simple mechanism for adding timestamps to the metadata field of Message and Artifact objects.

    Key learning objectives demonstrated by this extension include:

    • Defining extension protocols via specification documents.
    • Exposing extensions within AgentCards.
    • Activating extensions during the request/response lifecycle.
    • Augmenting base A2A types (like Message and Artifact).
    • Implementing extension libraries in a composable, standalone manner.
    • Versioning extensions by including the version in the URI.
  4. Overview of the A2A Server SDK

    main

    The A2A Server SDK is a Java implementation of the Agent-to-Agent (A2A) protocol server, built using Spring Boot and Spring AI. It provides a framework for building A2A-compliant agents capable of communicating with other A2A systems.

    Key capabilities include:

    • JSON-RPC 2.0 support for all protocol operations.
    • Agent Card publishing for metadata discovery.
    • Task Management for sending, querying, and cancelling operations.
    • Streaming Support via Server-Sent Events (SSE) for real-time task updates.
    • AI Integration via Spring AI, supporting providers like OpenAI and Azure OpenAI through the ChatClient abstraction.
  5. Overview of the Secure Passport Extension

    main

    The Secure Passport Extension v1 is an extension for the Agent2Agent (A2A) protocol that provides a trusted, contextual layer for agent communication. It enables a calling agent to securely share a structured subset of its current contextual state (e.g., loyalty tier, preferred currency) with a callee agent in a single step.

    Key benefits include:

    • Immediate Personalization: Allows specialist agents to act on user context immediately.
    • Reduced Overhead: Minimizes the need for multi-turn conversations to establish context.
    • Enhanced Trust: Uses a signature field to allow for cryptographic verification of the data's origin and integrity.
  6. Explore A2A samples by programming language

    main

    The repository contains core A2A samples organized by language. You can find implementations and SDK demonstrations in the following directories:

    DirectoryDescription
    samples/pythonPython agent implementations using the A2A Python SDK
    samples/goGo agent implementations using the A2A Go SDK
    samples/dotnetC# agent implementations using the A2A .NET SDK
    samples/javaJava agent implementations using the A2A Java SDK
    samples/jsNode.js agent implementations using the A2A JavaScript SDK
  7. Package structure of timestamp_ext

    main

    The timestamp_ext package is organized to separate core logic from server and client implementations:

    • timestamp_ext/core.py: Contains core metadata (URI, TIMESTAMP_FIELD) and the TimestampExtension class.
    • timestamp_ext/server.py: Contains server-side logic including wrap_executor, _TimestampingAgentExecutor, and _TimestampingEventQueue.
    • timestamp_ext/client.py: Contains client-side logic including wrap_client_factory and client_interceptor.
    • timestamp_ext/__init__.py: Exposes core public exports.
  8. A2A Java Project Architecture and Modules

    main

    The project is organized as a Maven multi-module project located in samples/java/:

    • model/ (Model Module): Contains the core A2A protocol data models for JSON-RPC 2.0 and A2A. Key models include:

      • Message Models: Message, Part, TextPart, Artifact
      • Task Models: Task, TaskStatus, TaskState
      • Agent Models: AgentCard, AgentCapabilities, AgentSkill
      • JSON-RPC Models: JSONRPCRequest, JSONRPCResponse, JSONRPCError
      • Event Models: TaskStatusUpdateEvent, TaskArtifactUpdateEvent
    • server/ (Server Module): A Spring Boot-based A2A server SDK integrated with Spring AI. It manages agent behavior via A2AServer, implements protocol endpoints via A2AController, and handles tasks through TaskHandler.

    • client/ (Client Module): A pure Java A2A client SDK. It uses A2AClient for all operations and supports synchronous/asynchronous tasks and streaming responses via StreamingEventListener.

  9. Explore .NET A2A Sample Demos

    main

    The .NET A2A Samples repository provides demonstrations of the Agent-to-Agent (A2A) SDK using different patterns. Available demos include:

    • BasicA2ADemo: Demonstrates core A2A concepts using an EchoServer (message echoing), a CalculatorServer (math operations), and a SimpleClient.
    • CLIAgent (A2ACliDemo): Demonstrates safe system command execution via a CLIServer (executes whitelisted commands) and a CLIClient.
    • AI-Powered Agent (A2ASemanticKernelDemo): Showcases intelligent agents using Microsoft Semantic Kernel. Includes an AIServer for text summarization, sentiment analysis, idea generation, and translation, paired with an AIClient.
  10. Understand the Python A2A sample structure

    main

    The Python samples are organized into three main categories:

    • Common: Contains shared code. Warning: Do not use this code for development; use the official A2A Python SDK instead.
    • Agents: Sample agents written in various frameworks that perform tasks using tools. These utilize the A2AServer.
    • Hosts: Host applications that use the A2AClient. Examples include a CLI for single-agent tasks, a Mesop web application for multi-agent interaction, and an orchestrator agent for delegating tasks to remote A2A agents.
  11. What is the Secure Passport extension?

    main
    The Secure Passport (v1) is a Profile/Data-Only extension for the A2A Protocol. It allows a client agent to securely share a structured, verifiable contextual state—the CallerContext—with a callee agent. This transforms anonymous A2A calls into trusted, context-aware interactions by providing identity (clientId), session continuity (sessionId), and verifiable state (state + signature).
  12. Core components of the A2A Server SDK

    main

    When building or extending an A2A agent with this SDK, you will interact with these primary classes:

    • A2AServer: The main server class that manages overall agent behavior.
    • A2AController: The REST controller responsible for implementing the A2A protocol endpoints.
    • TaskHandler: An interface used to implement custom agent logic for handling tasks.
    • A2AServerConfiguration: The configuration class used to set up the agent.