mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
ded32f3ff8
* Python: Add A2A server sample and fix client streaming bug 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 #4045 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review: handle CancelledError and fix end_date filtering - 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
83 lines
1.9 KiB
HTTP
83 lines
1.9 KiB
HTTP
### Each A2A agent is available at a different host address
|
|
@hostInvoice = http://localhost:5000
|
|
@hostPolicy = http://localhost:5001
|
|
@hostLogistics = http://localhost:5002
|
|
|
|
### Query agent card for the invoice agent
|
|
GET {{hostInvoice}}/.well-known/agent.json
|
|
|
|
### Send a message to the invoice agent
|
|
POST {{hostInvoice}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"id": "1",
|
|
"jsonrpc": "2.0",
|
|
"method": "message/send",
|
|
"params": {
|
|
"message": {
|
|
"kind": "message",
|
|
"role": "user",
|
|
"messageId": "msg_1",
|
|
"parts": [
|
|
{
|
|
"kind": "text",
|
|
"text": "Show me all invoices for Contoso"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
### Query agent card for the policy agent
|
|
GET {{hostPolicy}}/.well-known/agent.json
|
|
|
|
### Send a message to the policy agent
|
|
POST {{hostPolicy}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"id": "2",
|
|
"jsonrpc": "2.0",
|
|
"method": "message/send",
|
|
"params": {
|
|
"message": {
|
|
"kind": "message",
|
|
"role": "user",
|
|
"messageId": "msg_2",
|
|
"parts": [
|
|
{
|
|
"kind": "text",
|
|
"text": "What is the policy for short shipments?"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
### Query agent card for the logistics agent
|
|
GET {{hostLogistics}}/.well-known/agent.json
|
|
|
|
### Send a message to the logistics agent
|
|
POST {{hostLogistics}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"id": "3",
|
|
"jsonrpc": "2.0",
|
|
"method": "message/send",
|
|
"params": {
|
|
"message": {
|
|
"kind": "message",
|
|
"role": "user",
|
|
"messageId": "msg_3",
|
|
"parts": [
|
|
{
|
|
"kind": "text",
|
|
"text": "What is the status for SHPMT-SAP-001?"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|