Open
Conversation
Add a pure Python A2A server sample so testing the A2A client no longer requires running the .NET server. The server uses the a2a-sdk's A2AStarletteApplication with uvicorn and supports three agent types (invoice, policy, logistics) backed by AzureOpenAIResponsesClient. New files: - a2a_server.py: Main server entry point with CLI args - agent_executor.py: Bridges a2a-sdk AgentExecutor to Agent Framework - agent_definitions.py: Agent and AgentCard factory definitions - invoice_data.py: Mock invoice data and query tool functions - a2a_server.http: REST Client requests for testing Also fixes a streaming bug in agent_with_a2a.py where async with was used on ResponseStream which does not support the async context manager protocol. Changed to async for to match all other samples. Closes microsoft#4045 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Python A2A server sample under python/samples/04-hosting/a2a to enable testing the Python A2A client without requiring the .NET server, and fixes the streaming usage in the existing Python A2A client sample.
Changes:
- Introduces a runnable A2A server entry point (
a2a_server.py) backed bya2a-sdk+ uvicorn, with agent-type selection. - Adds supporting server modules: an
AgentExecutorbridge, Agent/AgentCard factories, and mock invoice data + tool functions. - Fixes the client streaming sample by iterating the
ResponseStreamwithasync forinstead of usingasync with.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/04-hosting/a2a/a2a_server.py | New Python A2A server entry point (uvicorn + A2AStarletteApplication) wiring AgentCard + request handler. |
| python/samples/04-hosting/a2a/agent_executor.py | Implements an AgentExecutor bridge from a2a-sdk requests to Agent Framework agent.run(). |
| python/samples/04-hosting/a2a/agent_definitions.py | Defines invoice/policy/logistics agent factories and AgentCard factories. |
| python/samples/04-hosting/a2a/invoice_data.py | Adds mock invoice dataset and query tools used by the invoice agent. |
| python/samples/04-hosting/a2a/agent_with_a2a.py | Fixes streaming consumption pattern for ResponseStream. |
| python/samples/04-hosting/a2a/a2a_server.http | Adds REST Client requests for manual testing of the server endpoints. |
| python/samples/04-hosting/a2a/README.md | Updates documentation to include server + client quickstart and file descriptions. |
You can also share your feedback on Copilot code review. Take the survey.
- Re-raise asyncio.CancelledError before the broad exception handler so cooperative cancellation is not swallowed. - Make end_date filter inclusive of the full day by comparing with < end + timedelta(days=1) instead of <= midnight. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a pure Python A2A server sample so testing the A2A client no longer requires running the .NET server. Also fixes a streaming bug in the existing client sample.
New Files
A2AStarletteApplication+ uvicorn, with CLI args for--agent-type(invoice/policy/logistics) and--portAgentExecutorinterface to Agent Framework agents@toolquery functionsBug Fix
Fixed
agent_with_a2a.pystreaming:ResponseStreamdoesn't implement the async context manager protocol, soasync withwas replaced withasync for(matching all other samples).Verified
/.well-known/agent.json, client connects with both non-streaming and streaming responsesCloses #4045