This project implements the A2A (Agent-to-Agent) π€π€π€ protocol using Microsoft's Semantic Kernel framework. The A2A protocol, proposed by Google, is designed as a communication protocol between AI agents.
Important
πΉThe official sample using Semantic Kernel was released one day after this repository.
πΉhttps://github.com/google/A2A > samples/python/agents/semantickernel/agent.py
βββ common/ # A2A protocol server/client
βββ sk/ # A2A agent implementation using Semantic Kernel
βββ sk_cli/ # A2A client sending a query to A2A agent
βββ sample/ # LangGraph sample (official implementation of A2A), which this project is based on.
sequenceDiagram
participant Client as sk_cli (Client)
participant Server as sk (A2A Server)
participant TaskManager as AgentTaskManager
participant Agent as CurrencyAgent
participant API as Frankfurter API
Client->>Server: Send request (JSON-RPC)
activate Server
Server->>TaskManager: Dispatch to task manager
activate TaskManager
TaskManager->>TaskManager: Create/update task
TaskManager->>Agent: Process user query
activate Agent
Note over TaskManager,Agent: Agent processing with SK
alt Streaming response
Agent-->>TaskManager: "Looking up exchange rates..."
TaskManager-->>Server: Stream working state
Server-->>Client: Stream event (JSON-RPC)
Agent-->>TaskManager: "Processing exchange rates..."
TaskManager-->>Server: Stream working state
Server-->>Client: Stream event (JSON-RPC)
end
Agent->>API: Call exchange rate API
activate API
API-->>Agent: Return exchange data
deactivate API
Agent-->>TaskManager: Final result
deactivate Agent
TaskManager->>TaskManager: Update task status
TaskManager-->>Server: Return completed task
deactivate TaskManager
Server-->>Client: Stream completed result (JSON-RPC)
deactivate Server
opt Push Notification configured
Server->>Client: Send push notification
end
- Create and activate the virtual environment:
python -m venv venv
# On Windows
venv\Scripts\activate
# On Unix or MacOS
source venv/bin/activate
- Install the required dependencies:
pip install poetry
poetry install
- Configure environment variables:
# Create a .env file with the following variables
AZURE_OPENAI_API_KEY=your_api_key
AZURE_OPENAI_ENDPOINT=your_endpoint
AZURE_OPENAI_DEPLOYMENT_NAME=your_deployment_name
- Start the A2A Agent Server:
python sk_main.py
- Send requests to the agent using the client:
python sk_cli_main.py
========= starting a new task ========
What do you want to send to the agent? (:q or quit to exit): How much is 100 USD in JPY?
stream event => {"jsonrpc":"2.0","id":"a2720b1bb297480a81a87914327b7fd8","result":{"id":"94a11ef59e724e21ab8be340f7df598f","status":{"state":"working","message":{"role":"agent","parts":[{"type":"text","text":"Looking up the exchange rates..."}]},"timestamp":"2025-04-16T16:21:05.490205"},"final":false}}
stream event => {"jsonrpc":"2.0","id":"a2720b1bb297480a81a87914327b7fd8","result":{"id":"94a11ef59e724e21ab8be340f7df598f","status":{"state":"working","message":{"role":"agent","parts":[{"type":"text","text":"Processing the exchange rates..."}]},"timestamp":"2025-04-16T16:21:14.840555"},"final":false}}
stream event => {"jsonrpc":"2.0","id":"a2720b1bb297480a81a87914327b7fd8","result":{"id":"94a11ef59e724e21ab8be340f7df598f","artifact":{"parts":[{"type":"text","text":"100 USD is equivalent to 14,293 JPY at the current exchange rate."}],"index":0,"append":false}}}
stream event => {"jsonrpc":"2.0","id":"a2720b1bb297480a81a87914327b7fd8","result":{"id":"94a11ef59e724e21ab8be340f7df598f","status":{"state":"completed","timestamp":"2025-04-16T16:21:14.842574"},"final":true}}