③ 问答
Agent Skills
一个 skill 就是一个装着 SKILL.md 的目录,通过 deepagents 原生的 SkillsMiddleware 提供给 DeepAgent,按需渐进披露。
skill 让你不写代码就能教会 agent 一套做法。它就是一个装着一份 Markdown 的目录:YAML frontmatter 说明这个 skill 用来干什么,正文说明具体怎么做。
Mirobody 对 Agent Skills 的支持走的是 deepagents 原生的 SkillsMiddleware:和 LangChain 自家 deep agent 用的是同一套机制,不是我们另写的加载器。
skill 与工具的区别
Section titled “skill 与工具的区别”- 工具
- 模型可以执行的代码
- skill
- 模型可以阅读的说明
工具扩展 agent 能做什么;skill 改变它怎么做:按什么顺序推进、拿什么去对照、什么话绝不能说。这里不执行任何代码:模型读这套流程,然后用它本来就有的那些工具去照做。
skill 的加载顺序
Section titled “skill 的加载顺序”-
SKILL_DIRS列出候选目录 随包默认是mirobody/agent/skills;把你自己的加上并列在最前面 - 第一个存在的目录被挂载 以只读方式挂在 DeepAgent 虚拟文件系统的
/skills/下 - 其中每个装着
SKILL.md的子目录就是一个 skill 不用注册、没有清单文件,除了重启本身也没有别的挂载钩子 -
SkillsMiddleware把每个 skill 的 frontmatter 注入提示词 所以 agent 随时知道自己手上有哪些 - 正文只在任务需要时才被读取 通过
/skills/挂载点,用 agent 自己的read_file
SKILL_DIRS: - skills # 你的,先查 - mirobody/agent/skills唯一必需的文件
Section titled “唯一必需的文件”一个 skill 就是一个带 SKILL.md 的目录。别的都不需要:没有清单文件,没有 JSON 附属文件,也没有脚本。
name、description)加说明正文 SKILL.md
Section titled “SKILL.md”先 YAML frontmatter,再 Markdown。真正承担契约的是两个键:
| 键 | 必需 | 作用 |
|---|---|---|
name | 是 | skill 的身份,与目录名一致。 |
description | 是 | 路由决策就靠它。 这一段会被注入每一次提示词,所以它必须同时说清这个 skill 做什么以及什么时候该用。 |
license、metadata | 否 | 自由字段;会被带着走,但不被解释。 |
---name: lab-report-walkthroughdescription: Walk a person through their lab report — read the original document, organize results by panel, flag out-of-range values against the printed reference ranges, compare with their history, and explain in plain language. Use when the user uploads a lab report (PDF/image) or asks what their blood test results mean.license: Apache-2.0metadata: author: thetahealth---
# Lab Report Walkthrough
Turn a raw lab report into an explanation a person can act on, without everdrifting into diagnosis.
## Workflow
1. **Read the original, not a summary.** …这就是 skill 能扩展、而「把提示词写得更长」不能的原因:
十个 skill 的常驻代价是十段描述,而不是十套流程。只有当 agent 判断某个 skill 用得上时,才为它的正文付费。
随包发布的 skill
Section titled “随包发布的 skill”随包只有一个 skill,而它就是给你照着写自己那个用的参照:
| Skill | 它编码了什么 |
|---|---|
lab-report-walkthrough | 读原始文档而不是抽取结果;按临床套餐而不是文档顺序组织;对照纸面上印的参考范围而不是记忆里的;有历史就先比历史;用平实语言解释;绝不滑向诊断。 |
其中有三步值得任何健康类 skill 原样照搬。参考范围随实验室、方法、年龄与性别而不同,所以纸面上那个范围胜过模型记住的任何范围。一个值是一个点,两个值才是一个方向,所以在开口之前值得先看历史。而把超出范围的排在最前、正常项用一行汇总掉的走查,正是「有用的回答」与「十五段『这个没事』」之间的差别。
编写自己的 skill
Section titled “编写自己的 skill”建目录
mkdir -p skills/medication-review写 SKILL.md
frontmatter 里给 name 与 description,然后写流程。步骤要编号;模型会按顺序照做。
---name: medication-reviewdescription: Review the user's current medications for interactions and timing conflicts. Use when the user asks about their medications, adds a new one, or asks whether two things can be taken together.---
# Medication Review
## Workflow
1. **Read what they actually take.** Call `query_health_indicators` for medication records before assuming anything from the conversation.2. **Group by mechanism, not by name.** Two brand names may be the same drug.3. **Name interactions as possibilities, not verdicts.** Say what to ask a pharmacist, and never tell someone to stop a prescribed medication.把 SKILL_DIRS 指过去并重启
SKILL_DIRS: - skills - mirobody/agent/skills只有第一个存在的目录会被挂载,所以把你自己的列在随包那个之前;如果两边都想要,就把随包那个 skill 复制一份,和你自己的放在同一个目录里。
确认它真的生效了
直接问 agent 它有哪些 skill。frontmatter 就在它的提示词里,所以它不必读取任何文件就能回答。
skill 的能力边界
Section titled “skill 的能力边界”- 它不能执行代码。 需要计算的流程必须去调工具,见添加自定义工具。
- 它不能授予权限。 一个让 agent 去读调用者无权访问的数据的 skill,照样会在工具边界上失败:身份是在那里强制的。
- 它不能限制工具。 工具可见性由配置里的
ALLOWED_TOOLS_*/DISALLOWED_TOOLS_*决定,不是 skill 能够收窄的范围。