# 关于自定义代理

Custom agents 通过量身定制的协助增强 Copilot。

## 关于 custom agents

Custom agents 是专用版本的 Copilot 代理，可针对独特的工作流、编码约定和用例进行定制。 他们的行为就像定制团队成员一样，遵循你的标准，使用正确的工具，并实施团队特定的做法。 定义这些代理一次，而不是重复提供相同的指令和上下文。

使用名为 custom agents 的 Markdown 文件进行定义agent profiles。 这些文件指定提示、工具和 MCP 服务器。 这样，就可以将约定、框架和所需结果直接编码为 Copilot。

agent profile定义custom agent的行为。 将代理分配到任务或问题时，它会实例化custom agent。

## Agent profile 格式

Agent profiles 是带有 YAML frontmatter 的 Markdown 文件。 在最简单的形式中，它们包括：

* **名称** （可选）：用于custom agent的显示名称。 如果省略，代理的文件名将用作其标识符和默认显示名称。
* **说明**：说明代理的用途和功能。
* **提示**：定义代理的行为和专业知识的自定义说明。
* **工具** （可选）：代理可以访问的特定工具。 默认情况下，代理可以访问所有可用的工具，包括内置工具和 MCP 服务器工具。

Agent profiles 还可以使用 `mcp-servers` 属性包含 MCP 服务器配置。

### 示例 agent profile

此示例是一个基本的 agent profile，配置了名称、描述和提示。

```text
---
name: readme-creator
description: Agent specializing in creating and improving README files
---

You are a documentation specialist focused on README files. Your scope is limited to README files or other related documentation files only - do not modify or analyze code files.

Focus on the following instructions:
- Create and update README.md files with clear project descriptions
- Structure README sections logically: overview, installation, usage, contributing
- Write scannable content with proper headings and formatting
- Add appropriate badges, links, and navigation elements
- Use relative links (e.g., `docs/CONTRIBUTING.md`) instead of absolute URLs for files within the repository
- Make links descriptive and add alt text to images
```

## 可配置 custom agents 的位置

可以在不同级别定义 agent profiles ：

* **存储库级别**：在存储库中创建项目特定的代理`.github/agents/CUSTOM-AGENT-NAME.md`。
* **组织级别**： `/agents/CUSTOM-AGENT-NAME.md` 在组织 `.github` 或 `.github-private` 存储库中创建，以便在组织内获得更广泛的可用性。
* **企业级**：在企业所有者于企业设置中指定的组织的 `.github-private` 仓库中创建 `/agents/CUSTOM-AGENT-NAME.md`，以便在企业中的所有仓库中可用。

有关详细信息，请参阅 [准备在组织中使用自定义代理](/zh/copilot/how-tos/administer-copilot/manage-for-organization/prepare-for-custom-agents) 和 [准备在企业中使用自定义代理](/zh/copilot/how-tos/administer-copilot/manage-for-enterprise/manage-agents/prepare-for-custom-agents)。

## 可在何处使用 custom agents

> \[!NOTE]
> Custom agents 位于适用于 JetBrains IDE、Eclipse 和 Xcode 的 公开预览 中，并且可能会更改。

创建custom agents后，这些将可用于以下方面：

* **Copilot cloud agentGitHub.com 上**：智能体选项卡和面板、问题分配和拉取请求
* **Copilot cloud agentIDE 中**：Visual Studio Code、JetBrains IDE、Eclipse 和 Xcode
* **GitHub Copilot CLI**

可以直接在 JetBrains IDE、Eclipse 和 Xcode 中使用agent profilesVisual Studio Code。 某些属性可能以不同的方式运行，或在环境之间被忽略。

有关在 custom agents 中使用 Visual Studio Code 的详细信息，请参阅 [Custom agents 中的 VS Code](https://code.visualstudio.com/docs/copilot/customization/custom-agents)。

## 后续步骤

若要创建自己的 custom agents帐户，请参阅：

* [为Copilot cloud agent创建自定义代理](/zh/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/create-custom-agents)
* [为 GitHub Copilot CLI 创建和使用自定义智能体](/zh/copilot/how-tos/copilot-cli/customize-copilot/create-custom-agents-for-cli)
* [Copilot自定义备忘单](/zh/copilot/reference/customization-cheat-sheet)