S
SkillNav

微软 Agent Framework 推出 Agent Skills:让智能体按需获得领域能力

资讯2026-03-02T16:46:27+00:009 分钟阅读
微软 Agent Framework 推出 Agent Skills:让智能体按需获得领域能力

March 2nd, 2026

like3 reactions

Sergey Menshykh

首席软件工程师

现在,你可以为 Microsoft Agent Framework 中的 Agent 配置可移植、可复用的技能包,让它们按需获得领域专业能力——而无需改动 Agent 核心指令中的任何一行代码。借助全新的 FileAgentSkillsProvider(.NET 和 Python 均可用),你的 Agent 可以在运行时发现并加载 Agent Skills,在需要时只拉取必要上下文。

什么是 Agent Skills?

Agent Skills 是一种简单且开放的格式,用于为 Agent 增加新能力与专业知识。每个 skill 的核心都是一个 SKILL.md 文件——这是一个 markdown 文档,用来描述 skill 的用途,并提供分步骤执行说明。skill 还可以包含可选脚本、参考文档和其他可按需获取的资源。

一个 skill 目录结构如下:

code
expense-report/
├── SKILL.md                          # 必需 — frontmatter + 指令
├── scripts/
│   └── validate.py                   # Agent 可执行的代码
├── references/
│   └── POLICY_FAQ.md                 # 按需加载的参考文档
└── assets/
    └── expense-report-template.md    # 模板和静态资源

SKILL.md 文件由 YAML frontmatter 元数据 + markdown 指令正文组成。只有 namedescription 是必填项;licensecompatibilitymetadata 等字段是可选项:

code
---
name: expense-report
description: >-
  File and validate employee expense reports according to company policy.
  Use when asked about expense submissions, reimbursement rules, or spending limits.
license: Apache-2.0                   # Optional
compatibility: Requires python3       # Optional
metadata:                             # Optional
  author: contoso-finance
  version: "2.1"
---

## Instructions

1. Ask the employee for their receipt and expense details...
2. Validate against the policy in references/POLICY_FAQ.md...

在以下场景中,skills 特别有价值:

  • 打包领域知识 —— 将专项知识(报销政策、法律流程、数据分析流水线)沉淀为可复用包。
  • 扩展 Agent 能力 —— 无需修改核心指令,就能为 Agent 增加新本领。
  • 确保一致性 —— 把多步骤任务固化为可重复、可审计的工作流。
  • 实现互操作性 —— 在不同兼容 Agent Skills 的产品之间复用同一 skill。

渐进式披露:以上下文效率为核心设计

Agent Skills 的关键设计原则之一是“渐进式披露(progressive disclosure)”。它不会在一开始把所有内容都塞进 Agent 上下文,而是分三阶段披露:

  1. 告知(Advertise)(每个 skill 约 100 tokens)—— 将 skill 名称与描述注入 system prompt,让 Agent 知道有哪些可用能力。
  2. 加载(Load)(建议 < 5,000 tokens)—— 当任务与某个 skill 匹配时,Agent 调用 load_skill 获取完整 SKILL.md 指令。
  3. 读取资源(Read resources)(按需)—— Agent 调用 read_skill_resource 仅在需要时拉取补充文件(参考资料、模板、assets)。

这种模式能让 Agent 的 context window 保持精简,同时在需要时仍可获取深度领域知识——当你的 Agent 需要处理多个领域,或希望严格控制 Token 使用量时,这一点尤其重要。

创建一个 Skill

最简单的 skill 只需要一个包含 SKILL.md 的文件夹。先创建 skills 目录,再在里面加一个 skill 子目录:

code
skills/
└── meeting-notes/
    └── SKILL.md

SKILL.md 以 YAML frontmatter 开头(namedescription 必填),后接 markdown 指令:

code
---
name: meeting-notes
description: >-
  Summarize meeting transcripts into structured notes with action items.
  Use when asked to process or summarize meeting recordings or transcripts.
---

## Instructions

1. Extract key discussion points from the transcript.
2. List any decisions that were made.
3. Create a list of action items with owners and due dates.
4. Keep the summary concise — aim for one page or less.

其中 description 字段尤为关键——Agent 会用它来判断何时加载该 skill,因此请同时写清“这个 skill 做什么”和“什么时候该用”。

就这么简单:不需要脚本,不需要额外文件——一个文件夹加一个 SKILL.md 即可。后续随着 skill 演进,你可以再添加 references/scripts/assets/ 目录。你也可以使用 skill-creator 这个 skill 来交互式生成新技能。

将 Skills 接入 Agent

FileAgentSkillsProvider 会从文件系统目录发现 skills,并以 context provider 的形式提供给 Agent。它会在配置路径中递归搜索(最多两层)SKILL.md 文件,校验其格式与资源,并将 skill 名称和描述注入 system prompt,让 Agent 知道可用技能。同时它还向 Agent 暴露两个工具:

  • load_skill —— 当 Agent 判断用户请求与某个 skill 领域匹配时,拉取完整 SKILL.md 指令,为任务提供详细分步指导。
  • read_skill_resource —— 获取 skill 打包的补充文件(references、templates、assets),让 Agent 仅在需要时引入额外上下文。

在 .NET 中使用 Skills

安装包:

code
dotnet add package Microsoft.Agents.AI --prerelease
dotnet add package Microsoft.Agents.AI.OpenAI --prerelease
dotnet add package Azure.AI.OpenAI --prerelease
dotnet add package Azure.Identity

配置 provider 并创建 Agent:

code
using Azure.AI.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using OpenAI.Responses;

// Discover skills from the 'skills' directory
var skillsProvider = new FileAgentSkillsProvider(
    skillPath: Path.Combine(AppContext.BaseDirectory, "skills"));

// Create an agent with the skills provider
AIAgent agent = new AzureOpenAIClient(
    new Uri(endpoint), new DefaultAzureCredential())
    .GetResponsesClient(deploymentName)
    .AsAIAgent(new ChatClientAgentOptions
    {
        Name = "SkillsAgent",
        ChatOptions = new()
        {
            Instructions = "You are a helpful assistant.",
        },
        AIContextProviders = [skillsProvider],
    });

// The agent discovers and loads matching skills automatically
AgentResponse response = await agent.RunAsync(
    "Summarize the key points and action items from today's standup meeting.");
Console.WriteLine(response.Text);

在 Python 中使用 Skills

安装包:

code
pip install agent-framework --pre

配置 provider 并创建 Agent:

code
from pathlib import Path
from agent_framework import FileAgentSkillsProvider
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity.aio import AzureCliCredential

# Discover skills from the 'skills' directory
skills_provider = FileAgentSkillsProvider(
    skill_paths=Path(__file__).parent / "skills"
)

# Create an agent with the skills provider
agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
    name="SkillsAgent",
    instructions="You are a helpful assistant.",
    context_providers=[skills_provider],
)

# The agent discovers and loads matching skills automatically
response = await agent.run(
    "Summarize the key points and action items from today's standup meeting."
)
print(response.text)

配置完成后,Agent 会自动发现可用 skills,并在用户任务与 skill 领域匹配时启用它们。你无需编写任何路由逻辑——Agent 会读取 system prompt 中的 skill 描述,并自行决定何时加载。

使用场景

以下是几个 Agent Skills 的典型应用:

企业政策合规

将公司 HR 政策、报销规则或 IT 安全规范打包为 skills。当员工询问“联合办公空间能报销吗?”时,面向员工的 Agent 可加载对应政策 skill,给出准确且有政策依据的回答——无需始终把全部政策放进上下文。

客服支持 Playbook

把支持团队的故障排查指南沉淀为 skills。客户报障后,Agent 可加载匹配的 playbook 并按文档步骤执行,无论请求落到哪个 Agent 实例,都能保持一致的处理质量。

多团队技能库

不同团队可以独立编写和维护各自 skills。你可以让 FileAgentSkillsProvider 指向多个目录并进行组合:

.NET

code
var skillsProvider = new FileAgentSkillsProvider(
    skillPaths: [
        Path.Combine(AppContext.BaseDirectory, "company-skills"),
        Path.Combine(AppContext.BaseDirectory, "team-skills"),
    ]);

Python

code
skills_provider = FileAgentSkillsProvider(
    skill_paths=[
        Path(__file__).parent / "company-skills",
        Path(__file__).parent / "team-skills",
    ]
)

每个路径既可以指向单个 skill 文件夹,也可以指向包含多个 skill 子目录的父目录。

安全性

请像对待开源依赖一样对待 skills——只使用可信来源,并在接入 Agent 前先审查。skill 指令会注入 Agent 上下文并影响其行为,因此你对新 package 应有的审慎态度,在这里同样适用。

接下来

我们会继续完善框架中的 Agent Skills 支持,后续包括:

  • Programmatic skills —— 通过 API 动态创建并注册 agent skills,支持在运行时生成或修改 skills,而不是仅依赖静态文件。
  • Agent skill execution —— 支持 Agent 执行 skill 内置脚本,使 skills 从“指令 + 参考资料”扩展到“主动代码执行”。

了解更多

想进一步了解并亲自体验,可查看文档与示例:

分类

主题

作者

Sergey Menshykh

首席软件工程师

原文链接:https://devblogs.microsoft.com/semantic-kernel/give-your-agents-domain-expertise-with-agent-skills-in-microsoft-agent-framework/

相关文章

AINews:Harness Engineering 到底是不是一门真学问?
深度·3月5日
AINews:Harness Engineering 到底是不是一门真学问?

这篇文章围绕 AI 工程中的核心争议展开:系统能力究竟主要来自更强的模型(Big Model),还是来自更强的编排层(Big Harness)。文中汇总了 OpenAI、Anthropic、Scale AI、METR 等多方观点与数据,显示两派在“模型进步会不会吞噬 Harness 价值”上分歧明显。作者最终认为,随着 Agent 产品落地加速,Harness Engineering 的独立价值正在被市场和社区进一步确认。

10 分钟
每个 Agent 都需要一个 Box:Aaron Levie 谈 AI 时代的新基础设施
深度·3月5日
每个 Agent 都需要一个 Box:Aaron Levie 谈 AI 时代的新基础设施

在围绕“AI 是否正在杀死 SaaS”的争论中,Box CEO Aaron Levie 提出相反观点:企业内容与文件系统在 Agent 时代反而更关键。随着 Filesystem、Sandbox 和 Agent 工作流快速普及,核心问题从“让 Agent 能做事”转向“如何治理 Agent 的身份、权限与安全边界”。他认为,未来企业将拥有远多于人的 Agent 数量,而真正的竞争力在于率先完成面向 Agent 的组织与基础设施改造。

8 分钟