用 Vercel Eve 的 Subagent 和 Skill 搭建 Agent Team
·
为什么需要 skill 和 subagent
前两篇里的 Agent 本质上还是聊天助手。它知道自己是 SpringForAll 内容运营助手,但选题、写作、审核和协作规则都挤在同一个上下文里:
- 选题应该怎么判断;
- 写作应该用什么结构;
- 审稿应该检查哪些风险;
- 谁负责研究,谁负责写作,谁负责审核;
- 某一步失败时应该重试,还是交给人判断。
如果全部塞进 agent/instructions.md,它很快会变成难维护的长期提示词,也会让每次调用都带上不需要的流程细节。所以这里按职责拆:
- instructions 写稳定身份、长期边界和团队协作规则;
- skills 写可按需加载的工作流;
- subagents 写角色边界和各自独立上下文。
放到内容团队里,就是:
topic_planning: 选题流程;article_writing: 写作流程;review_checklist: 审核流程;researcher: 研究员,负责研究和选题;writer: 撰稿人,负责大纲和草稿;reviewer: 审核人,负责审校和发布前风险检查;root agent: 内容主编,负责任务拆解和结果整合。

本节样例结构
最终目录如下:
example/03-content-team/
package.json
tsconfig.json
.env.example
scripts/
check-custom-gateway.mjs
agent/
agent.ts
instructions.md
lib/
model.ts
skills/
topic_planning.md
article_writing.md
review_checklist.md
subagents/
researcher/
agent.ts
instructions.md
skills/
topic_planning.md
writer/
agent.ts
instructions.md
skills/
article_writing.md
reviewer/
agent.ts
instructions.md
skills/
review_checklist.md
channels/
eve.ts
和第 02 篇相比,主要增加了:
agent/skills/: root agent 可加载的三份流程说明;agent/subagents/: 三个专职 subagents;agent/subagents/*/skills/: subagent 自己可加载的 skill。
注意一个 Eve 设计细节:
declared subagent 不会继承 root agent 的 authored slots。
root agent 有 agent/skills/topic_planning.md,不代表 researcher 自动拥有这个 skill。每个 declared subagent 都是独立的 agent root,只发现自己目录下的 instructions、skills、tools、connections、sandbox 等内容。
所以如果希望 researcher、writer、reviewer 自己加载并遵循某个 skill,就要在它们各自的 skills/ 目录下放一份。
复用第 02 篇的模型配置
先把模型入口放到公共文件里:
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
const defaultGatewayModelId = "minimax/minimax-m3";
const customBaseURL = process.env.EVE_MODEL_BASE_URL;
const usesCustomGateway = customBaseURL !== undefined && customBaseURL.trim() !== "";
完整文件在:
agent/lib/model.ts
它导出两个值:
export const model = usesCustomGateway
? createOpenAICompatible({
name: "custom",
baseURL: customBaseURL,
apiKey: process.env.EVE_MODEL_API_KEY,
includeUsage: true,
}).chatModel(requireCustomModelId())
: (process.env.EVE_GATEWAY_MODEL_ID ?? defaultGatewayModelId);
export const modelContextWindowTokens = parseContextWindowTokens(process.env.EVE_MODEL_CONTEXT_WINDOW_TOKENS);
root agent 和三个 subagents 都复用这份配置:
import { defineAgent } from "eve";
import { model, modelContextWindowTokens } from "#lib/model.js";
export default defineAgent({
model,
modelContextWindowTokens,
});
这样可以把重点留给 skills 和 subagents,避免每个 subagent 都复制 Provider 配置。当然实际应用不同 subagent 需要配置不同模型的话, 也可以为他们配置各自的 Provider 和 Model,本篇不做展开,读者也可以自己尝试。
编写 root agent:内容主编
root agent 的 instructions 升级为内容主编:
# SpringForAll Content Editor
You are the managing editor for the SpringForAll community content team.
Your mission is to help Java, Spring, Spring AI, Spring C更多推荐


所有评论(0)