创建云端 Custom agents
把专门职责、工具范围和行为说明保存为可复用的 agent profile。
This page has not been translated into English yet. The original Chinese version is shown below.
Custom agent 是具有专门职责和工具配置的 Copilot 角色。它适合测试、文档或实施规划等反复出现的工作;不需要每次任务重新粘贴整段角色说明。
创建 profile
- 打开 Agents 页面,选择目标仓库和分支。
- 在 agent 选择菜单点击 Create an agent,打开
.github/agents/my-agent.agent.md模板。 - 修改文件名和内容,明确职责、输入、输出与可用工具。
- 将文件合入默认分支,刷新 Agents 页面,在选择菜单中确认角色出现。
文件名只能含 . - _、大小写英文字母和数字。官方概念页使用 CUSTOM-AGENT-NAME.md,创建界面使用 .agent.md,配置参考明确支持这两种后缀。
一个规划角色
下面是按官方字段组织的示例,放在 .github/agents/implementation-planner.agent.md。它只开放读取与搜索,适合先返回计划,不在本轮生成计划文件或修改实现。
---
name: implementation-planner
description: "Investigates a change and proposes an implementation plan."
tools: ["read", "search"]
---
Inspect the relevant code and existing tests before proposing changes.
Describe the affected files, implementation steps, and acceptance criteria.
Return the plan in your response and identify unresolved assumptions.description 必填;省略 name 时,使用去掉 .md 或 .agent.md 后缀的文件名作为默认名称。Markdown 正文定义行为,最多 30,000 字符。
选择工具与范围
省略 tools 会启用全部可用工具,包括配置的 MCP;这并不是默认只读。限制为特定工具、禁用全部工具或选择 MCP 命名空间的方法见配置参考。
仓库级角色放在 .github/agents/。组织和企业共享角色使用专门仓库的根 agents/ 目录,发布范围不同,见组织与企业管理。
使用与迭代
从 Agents 标签页或面板提交任务时选择角色;分配 Issue 时也可以选择。代理创建 PR 后,会在 PR 描述中注明所用 custom agent。
Profile 以 Git commit SHA 记录版本。任务使用所选仓库和分支中的最新 profile;同一 PR 内的后续交互保持原角色版本,不能假定更新默认分支后会立即改变已存在 PR 的角色行为。
可以在 IDE 和 CLI 使用类似 profile,但字段支持不同。CLI 见创建与调用 Agents,IDE 见IDE Custom agents。