{"id":4663,"date":"2025-04-17T14:14:47","date_gmt":"2025-04-17T21:14:47","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=4663"},"modified":"2025-04-17T14:14:47","modified_gmt":"2025-04-17T21:14:47","slug":"integrating-semantic-kernel-python-with-googles-a2a-protocol","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/integrating-semantic-kernel-python-with-googles-a2a-protocol\/","title":{"rendered":"Integrating Semantic Kernel Python with Google&#8217;s A2A Protocol"},"content":{"rendered":"<p>Google&#8217;s Agent-to-Agent (A2A) protocol is designed to enable seamless interoperability among diverse AI agents. Microsoft\u2019s <strong>Semantic Kernel (SK)<\/strong>, an open-source platform for orchestrating intelligent agent interactions, is now being integrated into the A2A ecosystem. In this blog, we demonstrate how Semantic Kernel agents can easily function as an A2A Server, efficiently routing agent calls to specialized services.<\/p>\n<p>You can read more about the A2A protocol in Google&#8217;s <a href=\"https:\/\/google.github.io\/A2A\/#\/documentation\">technical documentation<\/a>.<\/p>\n<h2><strong>Our Contribution to the A2A Ecosystem<\/strong><\/h2>\n<p>Our initial contribution to the A2A repository addresses the current absence of a packaged A2A library, making it challenging for developers to quickly build integrations. Since the A2A protocol is still emerging, we\u2019re leveraging existing sample code directly from the A2A repository to demonstrate how Semantic Kernel agents can effectively integrate into this ecosystem. Our goal is to provide a clear integration path, enabling customers to easily adopt Semantic Kernel within their A2A projects.<\/p>\n<h2><strong>Key Components of the Integration<\/strong><\/h2>\n<h4><strong>SemanticKernelTravelManager<\/strong><\/h4>\n<p>The <strong>SemanticKernelTravelManager<\/strong> serves as the central coordinator, receiving and analyzing incoming requests. It intelligently routes these requests to specialized agents based on the context. For example, currency-related queries are sent directly to the <strong>CurrencyExchangeAgent<\/strong>, whereas activity or itinerary-related requests are forwarded to the <strong>ActivityPlannerAgent<\/strong>. This ensures optimal delegation and efficient response handling.<\/p>\n<h4><strong>CurrencyExchangeAgent<\/strong><\/h4>\n<p>This specialized agent handles currency-related tasks. It integrates external API tools, such as the <a href=\"https:\/\/www.frankfurter.app\/\" target=\"_blank\" rel=\"noopener\"><strong>Frankfurter API<\/strong><\/a>, to provide real-time currency exchange rates. By leveraging these data sources, the agent enables accurate budgeting and financial planning.<\/p>\n<h4><strong>ActivityPlannerAgent<\/strong><\/h4>\n<p>The <strong>ActivityPlannerAgent<\/strong> curates personalized travel experiences by offering tailored itinerary suggestions, activities, and event bookings based on user preferences and budgets.<\/p>\n<h3><strong>How Integration Works<\/strong><\/h3>\n<ul>\n<li><strong>Task Routing and Delegation<\/strong>: The TravelManager dynamically routes tasks to specialized agents, which are configured as plugins within the TravelManager itself. Leveraging context awareness and automatic function calling, the underlying model intelligently determines the most suitable agent to handle each request.<\/li>\n<li><strong>Agent Discovery<\/strong>: Agents advertise their capabilities through a structured &#8220;Agent Card,&#8221; enabling client agents to efficiently identify and select the most suitable agent for a given task, facilitating seamless communication through the A2A protocol. This example advertises one Semantic Kernel agent.<\/li>\n<li><strong>Conversational Memory<\/strong>: Semantic Kernel maintains context using its chat history across multi-turn interactions, providing a seamless user experience. In this sample the history is ephemeral and not persisted.<\/li>\n<\/ul>\n<h2><strong>Example Scenario<\/strong><\/h2>\n<p>Imagine a user wants a budget-friendly trip plan with currency conversion:<\/p>\n<ol>\n<li>User submits a request to the <strong>TravelManager<\/strong>.<\/li>\n<li>The TravelManager detects currency needs and invokes <strong>CurrencyExchangeAgent<\/strong>.<\/li>\n<li><strong>CurrencyExchangeAgent<\/strong> fetches rates from Frankfurter.<\/li>\n<li><strong>ActivityPlannerAgent<\/strong> suggests budget-friendly options.<\/li>\n<li>The TravelManager compiles and returns a complete trip plan.<\/li>\n<\/ol>\n<p><em><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/mermaid_a2a.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-4664\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/mermaid_a2a-1024x531.png\" alt=\"Mermaid Diagram of A2A and SK Agent Flow\" width=\"1024\" height=\"531\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/mermaid_a2a-1024x531.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/mermaid_a2a-300x155.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/mermaid_a2a-768x398.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/mermaid_a2a-1536x796.png 1536w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/mermaid_a2a-2048x1061.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/em><\/p>\n<h2><strong>Getting Started<\/strong><\/h2>\n<p>Ensure you have the latest version of the <a href=\"https:\/\/github.com\/google\/A2A\" target=\"_blank\" rel=\"noopener\">A2A repository<\/a> cloned locally to run this demo successfully.<\/p>\n<h3><strong>Prerequisites<\/strong><\/h3>\n<ul>\n<li>Python 3.10 or higher<\/li>\n<li><code>uv<\/code> package manager (see <a href=\"https:\/\/docs.astral.sh\/uv\/getting-started\/installation\/\">uv documentation<\/a> on how to install)<\/li>\n<li>Valid OpenAI credentials (see <a href=\"https:\/\/learn.microsoft.com\/en-us\/semantic-kernel\/concepts\/ai-services\/chat-completion\/?tabs=python-AzureOpenAI\" target=\"_blank\" rel=\"noopener\"><strong>SK documentation<\/strong><\/a>)<\/li>\n<li>Optional: Frankfurter API key, not required to hit the free endpoint<\/li>\n<\/ul>\n<h3><strong>Setup &amp; Running<\/strong><\/h3>\n<ol>\n<li><strong>Navigate to the Semantic Kernel sample in the A2A sample directory:<\/strong>\n<pre><code>cd samples\/python\/agents\/semantickernel<\/code><\/pre>\n<\/li>\n<li><strong>Create a .env file:<\/strong>\n<pre><code>OPENAI_API_KEY=\"your_api_key_here\"\r\nOPENAI_CHAT_MODEL_ID=\"your-model-id\"<\/code><\/pre>\n<\/li>\n<li><strong>Set up the environment (pin to your desired\/installed Python version):<\/strong>\n<pre><code>uv python pin 3.12\r\nuv venv\r\nsource .venv\/bin\/activate<\/code><\/pre>\n<\/li>\n<li><strong>Run the Semantic Kernel Agent:<\/strong>\n<pre><code># Default configuration\r\nuv run .\r\n\r\n# Otherwise run with a custom host and\/or port\r\nuv run . --host 0.0.0.0 --port 8080<\/code><\/pre>\n<\/li>\n<li><strong>Run the A2A Client (in separate terminal):<\/strong>\n<pre><code>cd samples\/python\r\nuv run hosts\/cli<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>After executing <code>uv run .<\/code> in the <code>samples\/python\/agents\/semantickernel<\/code> directory, you&#8217;ll observe <code>uv<\/code> installing the necessary packages. Once complete, you&#8217;ll see output similar to the following, indicating the server is up and running:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_server.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-4667\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_server-1024x260.png\" alt=\"SK A2A Agent Server\" width=\"1024\" height=\"260\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_server-1024x260.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_server-300x76.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_server-768x195.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_server.png 1519w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>When you run <code>uv run hosts\/cli<\/code> in the <code>samples\/python<\/code> directory, you&#8217;ll notice an Agent Card displayed, confirming that the Semantic Kernel Travel Agent Manager has been successfully discovered and is ready for interaction:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_client.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-4668\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_client-1024x388.png\" alt=\"SK A2A Client\" width=\"1024\" height=\"388\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_client-1024x388.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_client-300x114.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_client-768x291.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_client-1536x582.png 1536w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_client.png 1767w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>You can now send queries directly to the agent. For example: &#8220;I am traveling to Seoul, South Korea for 2 days. I have a budget of $100 USD a day. How much is that in South Korean Won? What sort of things can I do and eat?&#8221; Submitting this request initiates processing on the Semantic Kernel A2A Server, where the Travel Manager dynamically delegates tasks to its configured plugin agents. You&#8217;ll see streaming event messages in your console reflecting different stages of request handling\u2014these streaming events can also contain partial text responses in a production-ready scenario. Upon completion, you&#8217;ll receive a structured JSON response similar to the following:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_result.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-4669\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_result-1024x413.png\" alt=\"SK A2A Result\" width=\"1024\" height=\"413\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_result-1024x413.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_result-300x121.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_result-768x310.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_result-1536x620.png 1536w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/sk_a2a_result.png 1762w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h2><strong>What&#8217;s Next<\/strong><\/h2>\n<p>We&#8217;re actively developing additional integration samples, such as connecting with Azure AI Foundry via Semantic Kernel&#8217;s AzureAIAgent. Additionally, we&#8217;re planning to contribute an A2A sample directly to the Semantic Kernel repository. Stay tuned for future updates!<\/p>\n<h2>Share Your Feedback<\/h2>\n<p>Explore this sample in the A2A repository. As the A2A protocol continues to evolve, your insights and feedback are valuable to us. Let us know how you envision using the protocol for enhanced agent discovery, advanced multi-agent task coordination, and other innovative scenarios.<\/p>\n<p>Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google&#8217;s Agent-to-Agent (A2A) protocol is designed to enable seamless interoperability among diverse AI agents. Microsoft\u2019s Semantic Kernel (SK), an open-source platform for orchestrating intelligent agent interactions, is now being integrated into the A2A ecosystem. In this blog, we demonstrate how Semantic Kernel agents can easily function as an A2A Server, efficiently routing agent calls to [&hellip;]<\/p>\n","protected":false},"author":150043,"featured_media":4676,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[27,47,34,2],"tags":[135,53,136,9],"class_list":["post-4663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-agents","category-announcement","category-python-2","category-samples","tag-a2a","tag-python","tag-sample","tag-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Google&#8217;s Agent-to-Agent (A2A) protocol is designed to enable seamless interoperability among diverse AI agents. Microsoft\u2019s Semantic Kernel (SK), an open-source platform for orchestrating intelligent agent interactions, is now being integrated into the A2A ecosystem. In this blog, we demonstrate how Semantic Kernel agents can easily function as an A2A Server, efficiently routing agent calls to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/150043"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=4663"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/4676"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=4663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=4663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=4663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}