Skip to content

A2A (Agent-to-Agent) πŸ€–πŸ€πŸ€– protocol implementation using Semantic Kernel πŸ› οΈ(unofficial: Azure OpenAI)

Notifications You must be signed in to change notification settings

kimtth/a2a-protocol-semantic-kernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A2A Protocol Implementation with Semantic Kernel

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

Project Structure

β”œβ”€β”€ 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.

A2A Protocol Flow

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
Loading

Setup

  1. Create and activate the virtual environment:
python -m venv venv
# On Windows
venv\Scripts\activate
# On Unix or MacOS
source venv/bin/activate
  1. Install the required dependencies:
pip install poetry
poetry install
  1. 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

Usage

  1. Start the A2A Agent Server:
python sk_main.py
  1. Send requests to the agent using the client:
python sk_cli_main.py

Client CLI Examples

Example:

=========  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}}

Resources

About

A2A (Agent-to-Agent) πŸ€–πŸ€πŸ€– protocol implementation using Semantic Kernel πŸ› οΈ(unofficial: Azure OpenAI)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages