> ## 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 中使用子智能体

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

将自定义同步[子智能体](/oss/python/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/python/deepagents/data-locations#subagents)）。

frontmatter 需要 `name` 和 `description` 字段（与 [`SubAgent` 字典规范](/oss/python/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/python/deepagents/subagents#override-the-general-purpose-subagent)。

***

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

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