Skip to content

Commit 376bf2d

Browse files
authored
Improve the A2A agent sample. (#44383)
* Improve the A2A agent sample. * Return connection ID and add Changelog entry. * Fix
1 parent e563808 commit 376bf2d

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

sdk/ai/azure-ai-projects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* Added SharePoint grounding tool sample. See `sample_agent_sharepoint.py`.
3333
* Improved MCP client sample showing direct MCP tool invocation. See `samples/mcp_client/sample_mcp_tool_async.py`.
3434
* Samples that download generated files (code interpreter and image generation) now save files to the system temp directory instead of the current working directory. See `sample_agent_code_interpreter.py`, `sample_agent_code_interpreter_async.py`, `sample_agent_image_generation.py`, and `sample_agent_image_generation_async.py`.
35+
* The Agent to Agent sample was updated to allow "Custom keys" connection type.
3536

3637
## 2.0.0b2 (2025-11-14)
3738

sdk/ai/azure-ai-projects/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ Enable multi-agent collaboration where agents can communicate and delegate tasks
572572
tool = A2ATool(
573573
project_connection_id=os.environ["A2A_PROJECT_CONNECTION_ID"],
574574
)
575+
# If the connection is missing target, we need to set the A2A endpoint URL.
576+
if os.environ.get("A2A_ENDPOINT"):
577+
tool.base_url = os.environ["A2A_ENDPOINT"]
575578
```
576579

577580
<!-- END SNIPPET -->

sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_to_agent.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
the "Models + endpoints" tab in your Microsoft Foundry project.
2525
3) A2A_PROJECT_CONNECTION_ID - The A2A project connection ID,
2626
as found in the "Connections" tab in your Microsoft Foundry project.
27+
4) (Optional) A2A_ENDPOINT - If the connection is missing target i.e. if it is of "Custom keys" type, we need to set the A2A
28+
endpoint on the tool.
2729
"""
2830

2931
import os
@@ -49,6 +51,9 @@
4951
tool = A2ATool(
5052
project_connection_id=os.environ["A2A_PROJECT_CONNECTION_ID"],
5153
)
54+
# If the connection is missing target, we need to set the A2A endpoint URL.
55+
if os.environ.get("A2A_ENDPOINT"):
56+
tool.base_url = os.environ["A2A_ENDPOINT"]
5257
# [END tool_declaration]
5358

5459
agent = project_client.agents.create_version(
@@ -79,9 +84,14 @@
7984
print(f"\nFollow-up response done!")
8085
elif event.type == "response.output_item.done":
8186
item = event.item
82-
if item.type == "remote_function_call": # TODO: support remote_function_call schema
83-
print(f"Call ID: {getattr(item, 'call_id')}")
84-
print(f"Label: {getattr(item, 'label')}")
87+
if item.type == "a2a_preview_call":
88+
print(f"Request ID: {getattr(item, 'id')}")
89+
if hasattr(item, 'model_extra'):
90+
extra = getattr(item, 'model_extra')
91+
if isinstance(extra, dict):
92+
print(f"Arguments: {extra['arguments']}")
93+
elif item.type == "a2a_preview_call_output":
94+
print(f"Response ID: {getattr(item, 'id')}")
8595
elif event.type == "response.completed":
8696
print(f"\nFollow-up completed!")
8797
print(f"Full response: {event.response.output_text}")

0 commit comments

Comments
 (0)