你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
重要
本文中标记为(预览)的项目目前以公共预览版提供。 此预览版在没有服务级别协议的情况下提供,不建议将其用于生产工作负荷。 某些功能可能不受支持,或者可能具有受限功能。 有关详细信息,请参阅 Microsoft Azure 预览版的使用条款。
可以通过连接到支持
本文介绍如何配置 A2A 连接并从 Foundry 代理服务代理调用远程 A2A 终结点。
如果要将自己的代理 公开 为其他代理可以调用的 A2A 终结点,请参阅“托管 A2A 兼容的代理终结点”。
当 Foundry 代理通过 A2A 工具调用远程代理时,远程代理将处理请求并返回响应。 Foundry 代理使用该响应为用户生成答案,并继续管理聊天。
若要详细了解如何优化工具使用情况,请参阅 最佳做法。
注意
从 agent.as_tool 或连接的代理迁移?
新 Foundry 代理服务中不提供经典代理 API 中的连接代理工具。 若要将一个代理连接到另一个代理,请使用以下方法之一:
- A2A 工具 (本文):连接到任何 A2A 兼容的终结点,包括作为 A2A 终结点公开的另一个 Foundry 代理。 请参阅 “托管 A2A 兼容的代理终结点 ”,将 Foundry 代理设置为终结点。
- 工作流:使用顺序、群组聊天或人机循环模式以声明方式协调多个 Foundry 代理。 请参阅 在 Microsoft Foundry 中生成工作流。
有关经典代理工具与新 API 中的替换项的完整映射,请参阅 代理工具可用性。
使用支持
下表显示了 SDK 和设置支持。
| Microsoft Foundry 支持 | Python SDK | C# SDK | JavaScript SDK | Java SDK | REST API | 基本代理设置 | 标准代理设置 |
|---|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
先决条件
具有活跃 Foundry 项目的 Azure 订阅。
Foundry 项目中的模型部署(例如
gpt-4.1-mini)。所需 Azure 角色:在 Foundry 资源上,进行管理需要 Contributor 或 Owner,构建代理需要 Foundry User。
重要
Foundry RBAC 角色最近已更名。 Foundry 用户、Foundry 所有者、Foundry 帐户所有者和 Foundry 项目经理之前的名称分别为“Azure AI 用户”、“Azure AI 所有者”、“Azure AI 帐户所有者”和“Azure AI 项目经理”。 在重命名推出时,你仍可能会在某些位置看到以前的名称。重命名后,角色 ID 和核心权限保持不变。
SDK 安装:
- Python (GA):
pip install "azure-ai-projects>=2.0.0" - C#:
Azure.AI.ProjectsNuGet 包 - TypeScript (GA):
@azure/ai-projectsnpm 包 - Java:
com.azure:azure-ai-agents:2.0.0Maven 依赖项
- Python (GA):
代码中要更新的值:
- 项目端点 URL(例如,
https://<resource>.ai.azure.com/api/projects/<project>)。 - 模型部署名称(例如,
gpt-4.1-mini)。 - A2A 连接名称(在 Foundry 门户中创建)。
- A2A 基本 URI(可选,仅适用于非
RemoteA2A连接)。
- 项目端点 URL(例如,
在 Foundry 项目中配置的 A2A 连接。 有关连接设置和 REST 示例,请参阅 “创建 A2A 连接”。
创建 A2A 连接
为 A2A 终结点创建项目连接,以便安全地存储身份验证,并在代理版本中重复使用。
有关支持的身份验证方法的详细信息,请参阅 Agent2Agent (A2A) 身份验证。
如果要作为目标连接到 Foundry 代理,请将连接 目标 设置为目标代理的 A2A 基本路径, https://{account}.services.ai.azure.com/api/projects/{project}/agents/{agent}/endpoint/protocols/a2a并使用受众 https://ai.azure.com。 不要设置代理卡路径。 Foundry 会自动确定默认代理卡路径,并为你协商 A2A 协议版本。 目标代理必须已启用传入 A2A;请参阅 在 Foundry 代理上启用传入的 A2A。
在 Foundry 门户中创建连接
- 登录到 Microsoft Foundry。 确保 “新建 Foundry ”开关处于打开状态。 这些步骤适用于 Foundry(新版)。
- 选择 “工具”。
- 选择 连接工具。
- 选择“ 自定义 ”选项卡。
- 选择 Agent2Agent (A2A),然后选择“ 创建”。
- 输入 名称 和 A2A 代理终结点。
- 在 “身份验证”下,选择身份验证方法。 对于基于密钥的身份验证,请设置凭据名称(例如
x-api-key)和相应的机密值。
获取程序连接标识符
在代码中使用您的连接名称。 代码使用此名称检索运行时的完整连接 ID:
-
Python/C#/TypeScript:调用
project.connections.get(connection_name)以获取连接对象,然后访问connection.id。 -
REST API:在 A2A 工具定义的字段中包括连接 ID
project_connection_id。
使用 A2A 工具创建代理
选择 Prompt Agents以使用 Azure AI Projects SDK 创建服务器端提示代理,或托管代理使用 Agent Framework FoundryChatClient生成临时进程内代理。
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
PromptAgentDefinition,
A2APreviewTool,
)
# Format: "https://resource_name.ai.azure.com/api/projects/project_name"
PROJECT_ENDPOINT = "your_project_endpoint"
A2A_CONNECTION_NAME = "my-a2a-connection"
AGENT_NAME = "my-agent"
# Create clients to call Foundry API
project = AIProjectClient(
endpoint=PROJECT_ENDPOINT,
credential=DefaultAzureCredential(),
)
openai = project.get_openai_client()
# Create the A2A tool from the project connection
a2a_connection = project.connections.get(A2A_CONNECTION_NAME)
tool = A2APreviewTool(
project_connection_id=a2a_connection.id,
)
# Create the agent with the A2A tool
agent = project.agents.create_version(
agent_name=AGENT_NAME,
definition=PromptAgentDefinition(
model="gpt-5-mini",
instructions="You are a helpful assistant.",
tools=[tool],
),
)
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})")
接下来,向代理发送请求并输出响应:
# Send a request to the agent
response = openai.responses.create(
tool_choice="required",
input="What can the secondary agent do?",
extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}},
)
print(response.output_text)
# Clean up the created agent version
project.agents.delete_version(agent_name=agent.name, agent_version=agent.version)
预期输出
智能体返回有关辅助智能体功能的信息来做出响应,这表明 A2A 沟通成功。
使用 A2A 工具创建代理
此示例创建可以调用远程 A2A 终结点的代理。 有关连接设置步骤,请参阅 “创建 A2A 连接”。 选择 Prompt Agents 以使用 Azure AI Projects SDK 创建服务器端提示代理,或选择 Hosted Agents 以使用 Microsoft Agent Framework 通过将其中一个代理公开为另一个代理的函数工具,在进程内组合两个代理。
using System;
using Azure.AI.Projects;
using Azure.AI.Extensions.OpenAI;
using Azure.Identity;
var projectEndpoint = "https://<resource>.ai.azure.com/api/projects/<project>";
var a2aConnectionName = "my-a2a-connection";
var a2aBaseUri = "https://<a2a-endpoint>"; // Optional for non-RemoteA2A connections.
// Create project client to call Foundry API
AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential());
// Create the A2ATool and provide it with the A2A connection ID
AIProjectConnection a2aConnection = projectClient.Connections.GetConnection(connectionName: a2aConnectionName);
A2APreviewTool a2aTool = new()
{
ProjectConnectionId = a2aConnection.Id
};
if (!string.Equals(a2aConnection.Type.ToString(), "RemoteA2A"))
{
if (string.IsNullOrWhiteSpace(a2aBaseUri))
{
throw new InvalidOperationException($"The connection {a2aConnection.Name} is of {a2aConnection.Type.ToString()} type and does not carry the A2A service base URI. Set a2aBaseUri before running this sample.");
}
a2aTool.BaseUri = new Uri(a2aBaseUri);
}
// Create the agent with the A2A tool
DeclarativeAgentDefinition agentDefinition = new(model: "gpt-5-mini")
{
Instructions = "You are a helpful assistant.",
Tools = { a2aTool }
};
AgentVersion agentVersion = projectClient.AgentAdministrationClient.CreateAgentVersion(
agentName: "myAgent",
options: new(agentDefinition));
接下来,向代理发送请求并输出响应:
// Send the request and print the response
ProjectResponsesClient responseClient = projectClient.ProjectOpenAIClient.GetProjectResponsesClientForAgent(agentVersion.Name);
CreateResponseOptions responseOptions = new()
{
ToolChoice = ResponseToolChoice.CreateRequiredChoice(),
InputItems = { ResponseItem.CreateUserMessageItem("What can the secondary agent do?") },
};
ResponseResult response = responseClient.CreateResponse(responseOptions);
Console.WriteLine(response.GetOutputText());
// Clean up the created agent version
projectClient.AgentAdministrationClient.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version);
预期输出
控制台显示来自 A2A 终结点的代理响应文本。 完成后,将删除代理版本以清理资源。
使用 REST API 创建 A2A 连接
使用这些示例创建用于存储身份验证信息的项目连接。
若要获取Azure 资源管理器终结点的访问令牌,请执行以下操作:
az account get-access-token --scope https://management.azure.com/.default --query accessToken -o tsv
基于密钥
curl --request PUT \
--url 'https://management.azure.com/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group_name}}/providers/Microsoft.CognitiveServices/accounts/{{foundry_account_name}}/projects/{{project_name}}/connections/{{connection_name}}?api-version=2025-04-01-preview' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data '{
"tags": null,
"location": null,
"name": "{{connection_name}}",
"type": "Microsoft.MachineLearningServices/workspaces/connections",
"properties": {
"authType": "CustomKeys",
"group": "ServicesAndApps",
"category": "RemoteA2A",
"expiryTime": null,
"target": "{{a2a_endpoint}}",
"isSharedToAll": true,
"sharedUserList": [],
"Credentials": {
"Keys": {
"{{key_name}}": "{{key_value}}"
}
},
"metadata": {
"ApiType": "Azure"
}
}
}'
托管 OAuth 标识传递
在 Foundry 工具目录中选择托管 OAuth时,此选项受到支持。
curl --request PUT \
--url 'https://management.azure.com/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group_name}}/providers/Microsoft.CognitiveServices/accounts/{{foundry_account_name}}/projects/{{project_name}}/connections/{{connection_name}}?api-version=2025-04-01-preview' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data '{
"tags": null,
"location": null,
"name": "{{connection_name}}",
"type": "Microsoft.MachineLearningServices/workspaces/connections",
"properties": {
"authType": "OAuth2",
"group": "ServicesAndApps",
"category": "RemoteA2A",
"expiryTime": null,
"target": "{{a2a_endpoint}}",
"isSharedToAll": true,
"sharedUserList": [],
"useCustomConnector": false,
"connectorName": "{{connector_name}}",
"Credentials": {},
"metadata": {
"ApiType": "Azure"
}
}
}'
自定义 OAuth 身份透传
自定义 OAuth 不支持更新操作。 如果要更新某些值,请创建新的连接。
如果 OAuth 应用不需要客户端密码,则省略 ClientSecret。
注意
将每个范围作为数组中的 Scopes 单独字符串提供。 如果工具或 UI 需要范围作为单个字符串,请用 一个空格(而不是逗号)分隔它们,这遵循 OAuth 2.0 规范。
curl --request PUT \
--url 'https://management.azure.com/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group_name}}/providers/Microsoft.CognitiveServices/accounts/{{foundry_account_name}}/projects/{{project_name}}/connections/{{connection_name}}?api-version=2025-04-01-preview' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data '{
"tags": null,
"location": null,
"name": "{{connection_name}}",
"type": "Microsoft.MachineLearningServices/workspaces/connections",
"properties": {
"authType": "OAuth2",
"group": "ServicesAndApps",
"category": "RemoteA2A",
"expiryTime": null,
"target": "{{a2a_endpoint}}",
"isSharedToAll": true,
"sharedUserList": [],
"TokenUrl": "{{token_url}}",
"AuthorizationUrl": "{{authorization_url}}",
"RefreshUrl": "{{refresh_url}}",
"Scopes": [
"{{scope}}"
],
"Credentials": {
"ClientId": "{{client_id}}",
"ClientSecret": "{{client_secret}}"
},
"metadata": {
"ApiType": "Azure"
}
}
}'
Foundry 项目托管标识
curl --request PUT \
--url 'https://management.azure.com/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group_name}}/providers/Microsoft.CognitiveServices/accounts/{{foundry_account_name}}/projects/{{project_name}}/connections/{{connection_name}}?api-version=2025-04-01-preview' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data '{
"tags": null,
"location": null,
"name": "{{connection_name}}",
"type": "Microsoft.MachineLearningServices/workspaces/connections",
"properties": {
"authType": "ProjectManagedIdentity",
"group": "ServicesAndApps",
"category": "RemoteA2A",
"expiryTime": null,
"target": "{{a2a_endpoint}}",
"isSharedToAll": true,
"sharedUserList": [],
"audience": "{{audience}}",
"Credentials": {},
"metadata": {
"ApiType": "Azure"
}
}
}'
代理标识
curl --request PUT \
--url 'https://management.azure.com/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group_name}}/providers/Microsoft.CognitiveServices/accounts/{{foundry_account_name}}/projects/{{project_name}}/connections/{{connection_name}}?api-version=2025-04-01-preview' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data '{
"tags": null,
"location": null,
"name": "{{connection_name}}",
"type": "Microsoft.MachineLearningServices/workspaces/connections",
"properties": {
"authType": "AgenticIdentityToken",
"group": "ServicesAndApps",
"category": "RemoteA2A",
"expiryTime": null,
"target": "{{a2a_endpoint}}",
"isSharedToAll": true,
"sharedUserList": [],
"audience": "{{audience}}",
"Credentials": {},
"metadata": {
"ApiType": "Azure"
}
}
}'
将 A2A 工具添加到 Foundry 代理服务
获取访问令牌:
az account get-access-token --scope https://ai.azure.com/.default --query accessToken -o tsv
在请求中使用该令牌{{agent_token}}。
添加 A2A 工具的建议方法是通过工具箱,然后将工具箱作为 MCP 工具附加到代理。 请参阅 什么是工具箱?
- 创建包含 A2A 工具的工具箱:
curl --request POST \
--url '{{project_endpoint}}/toolboxes/a2a-toolbox/versions?api-version=v1' \
-H 'Content-Type: application/json' \
-d '{
"description": "Toolbox with the A2A tool",
"tools": [
{
"type": "a2a_preview",
"base_url": "{{a2a_endpoint}}",
"project_connection_id": "{{project_connection_id}}"
}
]
}'
工具箱公开了 MCP 兼容的终结点,该终结点 {{project_endpoint}}/toolboxes/a2a-toolbox/versions/<version>/mcp?api-version=v1是 <version> 上一次调用返回的版本。
使用用户 Entra 令牌创建指向工具箱终结点的远程工具项目连接,以便调用方的身份通过(受众
https://ai.azure.com) 传递。azd ai connection create a2a-toolbox-conn \ --kind remote-tool \ --target "{{project_endpoint}}/toolboxes/a2a-toolbox/versions/<version>/mcp?api-version=v1" \ --auth-type user-entra-token \ --audience https://ai.azure.com通过将工具箱附加为 MCP 工具,创建使用工具箱的代理版本:
curl --request POST \ --url '{{project_endpoint}}/agents/{{agent_name}}/versions?api-version=v1' \ -H 'Authorization: Bearer {{agent_token}}' \ -H 'Content-Type: application/json' \ -d '{ "description": "Test agent version description", "definition": { "kind": "prompt", "model": "{{model}}", "tools": [ { "type": "mcp", "server_label": "toolbox", "server_url": "{{project_endpoint}}/toolboxes/a2a-toolbox/versions/<version>/mcp?api-version=v1", "require_approval": "never", "project_connection_id": "a2a-toolbox-conn" } ], "instructions": "You are a helpful agent." } }'
若要删除代理版本,请将请求发送到具有相同代理名称和版本的同一 DELETE 终结点。
使用Azure开发人员 CLI 将 A2A 工具添加到工具箱
为远程代理创建一个 remote-a2a 连接,然后在一个最简工具箱 YAML 中引用该连接。
第 1 步。 创建连接
选择所需的身份验证变体:
# No auth
azd ai connection create my-a2a-conn \
--kind remote-a2a \
--target https://your-remote-agent.azurecontainerapps.io \
--auth-type none
# Custom-keys header
azd ai connection create my-a2a-conn \
--kind remote-a2a \
--target https://your-remote-agent.azurecontainerapps.io \
--auth-type custom-keys \
--custom-key "Authorization=******"
# OAuth — bring your own app registration
azd ai connection create my-a2a-conn \
--kind remote-a2a \
--target https://your-remote-agent.azurecontainerapps.io \
--auth-type oauth2 \
--authorization-url https://auth.example.com/authorize \
--token-url https://auth.example.com/token \
--client-id <oauth-client-id> \
--client-secret <oauth-client-secret> \
--scopes "<scope1> <scope2>"
# User Entra token (managed user identity passthrough)
azd ai connection create my-a2a-conn \
--kind remote-a2a \
--target https://your-remote-agent.azurecontainerapps.io \
--auth-type user-entra-token \
--audience "<entra-audience>"
# Project managed identity
azd ai connection create my-a2a-conn \
--kind remote-a2a \
--target https://your-remote-agent.azurecontainerapps.io \
--auth-type project-managed-identity \
--audience "<entra-audience>"
# Agentic identity
azd ai connection create my-a2a-conn \
--kind remote-a2a \
--target https://your-remote-agent.azurecontainerapps.io \
--auth-type agentic-identity \
--audience "<entra-audience>"
--auth-type |
其他标志 |
|---|---|
none |
— |
custom-keys |
--custom-key "Header=Value" (可重复) |
oauth2 |
--authorization-url、--token-url、--client-id、--client-secret、--scopes |
user-entra-token |
--audience <entra-audience> |
project-managed-identity |
--audience <entra-audience>(可选) |
agentic-identity |
--audience <entra-audience> |
步骤 2。 定义工具箱
# my-toolbox.yaml
description: Agent-to-Agent toolbox
connections:
- name: my-a2a-conn
步骤 3。 创建工具箱
azd ai toolbox create my-toolbox --from-file my-toolbox.yaml
此示例演示如何使用 a2a_preview 工具类型和 Azure AI Projects 客户端创建具有 A2A 功能的 AI 代理。 代理与其他代理通信,并使用 A2A 协议基于代理间交互提供响应。
import { DefaultAzureCredential } from "@azure/identity";
import { AIProjectClient } from "@azure/ai-projects";
const PROJECT_ENDPOINT = "https://<resource>.ai.azure.com/api/projects/<project>";
const A2A_CONNECTION_NAME = "my-a2a-connection";
// Create clients to call Foundry API
const project = new AIProjectClient(PROJECT_ENDPOINT, new DefaultAzureCredential());
const openai = project.getOpenAIClient();
// Get the A2A connection by name to retrieve its ID
const a2aConnection = await project.connections.get(A2A_CONNECTION_NAME);
// Add the A2A tool to a toolbox
const toolbox = await project.toolboxes.createVersion(
"a2a-toolbox",
[
{
type: "a2a_preview",
project_connection_id: a2aConnection.id,
},
],
{ description: "Toolbox with the A2A tool" },
);
// The toolbox exposes an MCP-compatible endpoint
const toolboxMcpUrl =
`${PROJECT_ENDPOINT}/toolboxes/${toolbox.name}` +
`/versions/${toolbox.version}/mcp?api-version=v1`;
创建指向工具箱终结点的远程工具项目连接。 使用用户 Entra 令牌,以便调用方的身份通过 (受众 https://ai.azure.com) 传递。 创建连接一次,例如使用Azure开发人员 CLI:
azd ai connection create a2a-toolbox-conn \
--kind remote-tool \
--target "<toolboxMcpUrl>" \
--auth-type user-entra-token \
--audience https://ai.azure.com
接下来,将工具箱作为 MCP 工具附加到提示代理,并运行它:
const toolboxConnectionName = "a2a-toolbox-conn";
// Attach the toolbox to a prompt agent as an MCP tool
const agent = await project.agents.createVersion("MyA2AAgent", {
kind: "prompt",
model: "gpt-5-mini",
instructions: "You are a helpful assistant.",
tools: [
{
type: "mcp",
server_label: "toolbox",
server_url: toolboxMcpUrl,
require_approval: "never",
project_connection_id: toolboxConnectionName,
},
],
});
console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
// Send a request to the agent
const response = await openai.responses.create(
{
input: "What can the secondary agent do?",
},
{
body: {
agent: { name: agent.name, type: "agent_reference" },
tool_choice: "required",
},
},
);
console.log(response.output_text);
// Clean up the created agent version
await project.agents.deleteVersion(agent.name, agent.version);
预期输出
控制台显示来自 A2A 终结点的代理响应文本。 完成后,将删除代理版本以清理资源。
在 Java 中使用代理到代理通信
创建工具箱后,在Java代理中更新这些值:
-
projectEndpoint— 项目终结点。 -
toolboxMcpUrl— 包含 A2A 工具的工具箱版本的 MCP 终结点。 -
toolboxConnectionName— 工具箱终结点的远程工具项目连接名称。
将依赖项添加到pom.xml。
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-agents</artifactId>
<version>2.2.0</version>
</dependency>
提示
推荐: 对于大多数代理,通过 工具箱 添加 A2A 工具,并将工具箱作为 MCP 工具附加到代理。 Java SDK 尚未公开工具箱创建 API,因此使用 Python、REST API、C# 或 TypeScript 示例或 Foundry 门户创建工具箱,然后从Java代理引用其 MCP 终结点作为一个McpTool。
故障 排除
| 问题 | 原因 | 分辨率 |
|---|---|---|
| 代理不调用 A2A 工具 | 代理定义不包括 A2A 工具配置 | 确认代理定义包括 A2A 工具和配置连接。 如果使用响应,请确认未强制使用其他工具。 |
| 代理不调用 A2A 工具 | 提示不需要远程代理 | 更新提示以要求调用远程代理,或删除冲突的工具选择设置。 |
| 身份验证失败(401 或 403) | 连接身份验证类型不匹配 | 确认连接的身份验证类型符合终结点要求。 对于基于密钥的身份验证,请确认凭据名称与终结点所需的名称匹配(x-api-key 或 Authorization)。 |
| SDK 示例找不到连接 | 连接名称不匹配 | 确认代码中的连接名称与 Foundry 中的连接名称匹配。 |
| 网络或 TLS 错误 | 端点不可达或证书无效 | 确认终结点是可公开访问的,并使用有效的 TLS 证书。 检查防火墙规则和代理设置。 |
| 远程代理返回意外响应 | 响应格式不兼容 | 确认远程代理遵循 A2A 协议规范。 检查响应内容类型是否与预期格式匹配。 |
| 连接超时 | 远程代理响应速度缓慢 | 增加超时设置或验证远程代理的性能。 请考虑使用指数退避实现重试逻辑。 |
| 响应中缺少 A2A 工具 | 未为智能体启用工具 | 使用显式启用 A2A 工具重新创建代理,并验证连接是否处于活动状态且配置正确。 |
托管 A2A 兼容的代理端点
可以通过在代理上启用 A2A 协议,直接将 Foundry 代理公开为 A2A 终结点。 有关分步说明,请参阅在 Foundry 智能体上启用传入 A2A。
如果代理部署在代理服务外部,或者需要自定义托管方法,请使用以下替代方法之一。
选项 1:在 Foundry 控制平台中注册自定义 A2A 代理
如果已在代理服务外部部署了支持 A2A 协议的代理,请在 Foundry 控制平面中注册该代理,以便集中管理、可观测性和治理。
- 将 A2A 兼容的代理部署到任何可访问的终结点。
- 在 Foundry 控制平面中注册代理,然后选择 A2A 作为协议。
- Foundry 生成一个智能体 URL,并在
/.well-known/agent-card.json处发现智能体卡。
注册后,其他代理程序可以通过代理 URL 连接到您的代理程序。 Foundry 通过 AI 网关提供访问控制和监视。
有关身份验证设置,请参阅 Agent2Agent (A2A) 身份验证。
选项 2:构建一个封装 Foundry 代理的自定义 A2A 服务器
构建一个轻型 A2A 服务器,该服务器通过响应 API 委托给 Foundry 代理:
- 使用适用于语言的官方 A2A SDK(Python、.NET 或 JavaScript)创建 A2A 服务器。
- 实现服务器以通过响应 API 调用 Foundry 代理。
- 在
/.well-known/agent-card.json提供描述智能体功能的智能体卡片。 - 部署服务器并在 Foundry 控制平面中注册它。
有关服务器的 A2A 协议要求的详细信息,请参阅 A2A 规范。
使用非Microsoft 服务的注意事项
使用连接的非微软服务和服务器时,你将受你与服务提供商之间条款的约束。 根据你所管理的使用 Microsoft Online 服务的协议,非Microsoft服务属于非Microsoft产品。 连接到非Microsoft服务时,会将某些数据(如提示内容)传递给非Microsoft 服务,或者应用程序可能会从非Microsoft 服务接收数据。 你需要对你使用非 Microsoft 服务和数据负责,并承担因此产生的任何费用。
非 Microsoft 服务(包括 A2A 智能体终结点)是由第三方(而非 Microsoft)创建的,你可决定将此类服务与本文所述的 A2A 工具结合使用。 Microsoft未测试或验证这些 A2A 代理终结点。 Microsoft对您或其他人使用任何非Microsoft服务不承担任何责任。
仔细查看并持续监控您添加到 Foundry 代理服务中的 A2A 代理端点。 依赖于受信任的服务提供商本身托管的终结点,而不是代理。
使用 A2A 工具可以传递 A2A 代理终结点可能需要的自定义标头,例如身份验证密钥或架构。 查看您与非 Microsoft 服务共享的所有数据,包括 A2A 代理终结点,并将数据记录下来以用于审核。 请注意有关保留和数据位置的非Microsoft做法。