Anthropic 最新前沿模型 Claude Fable 5 今天正式上线 Microsoft Foundry,同时成为 GitHub Copilot 和 Foundry Agent Service 的底层驱动力。这意味着开发者不再需要绕道第三方 API,直接在 Azure 生态内就能调用 Anthropic 最强的推理能力来构建自主 Agent。
为什么值得关注
过去一年,"自主 Agent"从概念走向工程落地,但瓶颈一直很明确:模型推理能力不够、工具调用不稳定、长任务上下文丢失。Claude Fable 5 作为 Anthropic 的最新前沿模型,在指令遵循、多步推理和工具使用方面有显著提升——这三项恰好是自主 Agent 能否可靠运行的核心指标。
现在它直接集成进 Microsoft Foundry,带来的不只是模型本身:
- GitHub Copilot 将用 Fable 5 增强 Agent 式编程辅助,从"补全代码"升级为"理解意图、拆解任务、逐步执行"。
- Foundry Agent Service 提供了托管化的 Agent 运行环境,开发者专注定义 Agent 行为,基础设施由 Azure 承担。
在 Foundry 中部署 Claude Fable 5
模型上线后,第一步是在 Azure AI Foundry 中创建模型部署。以下是通过 Azure CLI 完成部署的完整流程:
# 1. 登录 Azure
az login
# 2. 设置目标订阅(替换为你的订阅 ID)
az account set --subscription "your-subscription-id"
# 3. 创建 AI Services 资源(如果还没有)
az group create --name agent-rg --location eastus2
az cognitiveservices account create \
--name fable5-ai-service \
--resource-group agent-rg \
--kind AIServices \
--sku S0 \
--location eastus2
# 4. 部署 Claude Fable 5 模型
az cognitiveservices account deployment create \
--name fable5-ai-service \
--resource-group agent-rg \
--deployment-name claude-fable5 \
--model-format Anthropic \
--model-name claude-fable-5 \
--model-version 1 \
--sku-capacity 1 \
--sku-name GlobalStandard
部署完成后,在 Foundry 门户中可以看到模型 endpoint 和 API key,也可以直接通过 SDK 调用。
用 Python SDK 调用 Fable 5 构建 Agent
Azure AI Inference SDK 已经支持 Anthropic 模型格式。下面是一个最小可运行的 Agent 示例——它接收用户任务,拆解为步骤,逐步执行并汇报结果:
# pip install azure-ai-inference azure-identity
import os
from azure.ai.inference import ChatCompletionsClient
from azure.identity import DefaultAzureCredential
from azure.core.credentials import AccessToken
# 使用 Azure 身份认证(推荐),也可换成 API Key
credential = DefaultAzureCredential()
client = ChatCompletionsClient(
endpoint="https://fable5-ai-service.services.ai.azure.com/openai/deployments/claude-fable5",
credential=credential,
api_version="2025-04-01-preview", # 根据实际支持的版本调整
)
# 定义 Agent 的系统提示——强调自主执行
system_prompt = """你是一个自主执行 Agent。收到任务后:
1. 将任务拆解为可执行的子步骤
2. 对每个子步骤,说明执行动作和预期结果
3. 如果需要外部工具,明确声明工具名称和参数
4. 最后汇总所有步骤的结果
格式要求:每个步骤用 [Step N] 标记,结果用 [Result] 标记。"""
user_task = "分析一份 Python 项目的依赖树,找出存在安全漏洞的包,并给出升级建议。"
response = client.complete(
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_task},
],
max_tokens=4096,
temperature=0.3, # Agent 任务建议低温度,减少随机性
)
print(response.choices[0].message.content)
运行前需要确认:
- endpoint 替换为你实际创建的 AI Services 资源地址
- api_version 使用 Foundry 当前支持的预览版本
- 如果用 API Key 认证,将 credential 替换为 AzureKeyCredential(os.environ["AZURE_AI_KEY"])
Foundry Agent Service:从单次调用到持续运行
单次 chat.complete 适合演示,但真正的自主 Agent 需要持久运行、状态管理、工具编排。Foundry Agent Service 正是为此设计的托管运行层。
以下 YAML 定义了一个最小 Agent 配置,可以上传到 Foundry Agent Service:
# agent-config.yaml
agent:
name: dependency-security-agent
description: "分析项目依赖安全漏洞并给出升级建议"
model:
provider: Anthropic
name: claude-fable-5
version: "1"
# Agent 可使用的工具——这里声明两个内置工具
tools:
- name: run_shell_command
type: builtin
description: "执行 shell 命令并返回输出"
parameters:
command:
type: string
required: true
- name: read_file
type: builtin
description: "读取项目文件内容"
parameters:
path:
type: string
required: true
# Agent 行为约束
instructions: |
你是依赖安全分析 Agent。
工作流程:
1. 用 read_file 读取 requirements.txt 或 pyproject.toml
2. 用 run_shell_command 运行 pip audit 或 safety check
3. 分析漏洞报告,按严重程度排序
4. 给出每个漏洞包的升级版本建议
不要修改任何文件,只输出分析报告。
# 运行策略
execution:
max_steps: 10 # 最多执行 10 个工具调用步骤
timeout_seconds: 300 # 单次运行超时 5 分钟
retry_on_failure: true # 工具调用失败时自动重试
将此配置通过 Foundry 门户或 REST API 提交后,Agent Service 会创建一个可调度的 Agent 实例。你可以通过 HTTP 触发它执行任务:
# 触发 Agent 执行(替换为你的 Agent Service endpoint)
curl -X POST \
"https://your-agent-service.azure.net/agents/dependency-security-agent/run" \
-H "Authorization: Bearer $(az account get-access-token --query accessToken -o tsv)" \
-H "Content-Type: application/json" \
-d '{"task": "分析当前项目的依赖安全性"}'
落地前的几项考量
成本与速率限制——Fable 5 是前沿模型,token 计费高于轻量模型。Agent 场景中长上下文 + 多步调用会快速消耗 token,建议先用 Claude Haiku 级别模型做原型验证,确认流程后再切换到 Fable 5。
工具权限边界——Agent Service 的 run_shell_command 能力很强,也意味着风险。生产环境中务必限定可执行命令的白名单,避免 Agent 自主执行破坏性操作。
模型版本锁定——前沿模型迭代速度快,部署时建议锁定 model-version,防止自动升级导致行为变化。YAML 中的 version: "1" 就是这个用途。
混合模型策略——不是每个步骤都需要前沿推理。实际 Agent 工作流中,可以把任务拆解和最终决策交给 Fable 5,中间的信息提取、格式转换交给更便宜的模型,用 Foundry 的路由能力实现成本优化。
Claude Fable 5 进入 Microsoft Foundry,本质上是把 Anthropic 最强的推理能力嵌进了 Azure 的 Agent 基础设施。对开发者来说,从模型到 Agent 运行环境再到 Copilot 集成,链条已经闭合。下一步不是"能不能用",而是"怎么用得稳、用得省"。