Skip to content

Commit ef44fb4

Browse files
authored
azureai direct a2a endpoint support (microsoft#3127)
1 parent e63c148 commit ef44fb4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

python/samples/getting_started/agents/azure_ai/azure_ai_with_agent_to_agent.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,31 @@
1414
Prerequisites:
1515
1. Set AZURE_AI_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME environment variables.
1616
2. Ensure you have an A2A connection configured in your Azure AI project
17-
and set A2A_PROJECT_CONNECTION_ID environment variable.
17+
and set A2A_PROJECT_CONNECTION_ID environment variable.
18+
3. (Optional) A2A_ENDPOINT - If the connection is missing target (e.g., "Custom keys" type),
19+
set the A2A endpoint URL directly.
1820
"""
1921

2022

2123
async def main() -> None:
24+
# Configure A2A tool with connection ID
25+
a2a_tool = {
26+
"type": "a2a_preview",
27+
"project_connection_id": os.environ["A2A_PROJECT_CONNECTION_ID"],
28+
}
29+
30+
# If the connection is missing a target, we need to set the A2A endpoint URL
31+
if os.environ.get("A2A_ENDPOINT"):
32+
a2a_tool["base_url"] = os.environ["A2A_ENDPOINT"]
33+
2234
async with (
2335
AzureCliCredential() as credential,
2436
AzureAIClient(credential=credential).create_agent(
2537
name="MyA2AAgent",
2638
instructions="""You are a helpful assistant that can communicate with other agents.
2739
Use the A2A tool when you need to interact with other agents to complete tasks
2840
or gather information from specialized agents.""",
29-
tools={
30-
"type": "a2a_preview",
31-
"project_connection_id": os.environ["A2A_PROJECT_CONNECTION_ID"],
32-
},
41+
tools=a2a_tool,
3342
) as agent,
3443
):
3544
query = "What can the secondary agent do?"

0 commit comments

Comments
 (0)