> ## Documentation Index
> Fetch the complete documentation index at: https://nvd-54.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 在 CLI 中使用子智能体

> 以 AGENTS.md 文件和 YAML frontmatter 定义自定义深度智能体 CLI 子智能体。涵盖项目和用户路径、可选的模型覆盖及示例。

将自定义同步[子智能体](/oss/javascript/deepagents/subagents)定义为 markdown 文件，以便 CLI 智能体可以将专门的任务委派给它们。

<Note>
  异步子智能体目前在深度智能体 CLI 中不可用。
</Note>

每个子智能体都有自己的文件夹和一个 `AGENTS.md` 文件：

```text theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
.deepagents/agents/{subagent-name}/AGENTS.md   # 项目级
~/.deepagents/{agent}/agents/{subagent-name}/AGENTS.md  # 用户级
```

同名时项目级子智能体会覆盖用户级子智能体（参见[优先级规则](/oss/javascript/deepagents/data-locations#subagents)）。

frontmatter 需要 `name` 和 `description`（与 [`SubAgent` 字典规范](/oss/javascript/deepagents/subagents#subagent-dictionary-based)相同）。markdown 正文将成为子智能体的 `system_prompt`。除了基本规范外，`AGENTS.md` 文件还支持可选的 `model` frontmatter 字段，用于覆盖该子智能体使用的主智能体模型。使用 `provider:model-name` 格式（例如 `anthropic:claude-opus-4-7`、`openai:gpt-5.5`）。省略则继承主智能体的模型。

<Note>
  其他 `SubAgent` 字段（`tools`、`middleware`、`interrupt_on`、`skills`）目前无法通过 `AGENTS.md` frontmatter 配置——以这种方式定义的自定义子智能体会继承主智能体的工具。如需完全控制，请直接使用 SDK。
</Note>

## 文件格式

子智能体 `AGENTS.md` 文件使用 YAML frontmatter 加 markdown 正文：

```markdown theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
---
name: researcher
description: Research topics on the web before writing content
model: anthropic:claude-haiku-4-5-20251001
---

You are a research assistant with access to web search.

## Your Process
1. Search for relevant information
2. Summarize findings clearly
```

## 示例：高性价比子智能体

对简单的委派任务使用更便宜、更快速的模型，同时让主智能体保持使用更强大的模型：

```markdown theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
---
name: general-purpose
description: General-purpose agent for research and multi-step tasks
model: anthropic:claude-haiku-4-5-20251001
---

You are a general-purpose assistant. Complete the task efficiently and return a concise summary.
```

这将覆盖内置的通用子智能体，将所有委派的任务路由到更便宜的模型。详见[覆盖通用子智能体](/oss/javascript/deepagents/subagents#override-the-general-purpose-subagent)。

***

<div className="source-links">
  <Callout icon="terminal-2">
    [通过 MCP 连接这些文档](/use-these-docs)到 Claude、VSCode 等以获取实时解答。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/deepagents/cli/subagents.mdx) 或 [提交 issue](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
