> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Subagent 服务器工具

> 让主模型将特定任务委托给工作模型。

如果主模型需要在同一请求中将独立任务交给更小或更快的工作模型，请使用 `phaseo:subagent`。

主模型通过任务说明调用 Subagent 工具。Phaseo 在服务器端运行工作模型，将其结果作为工具上下文返回，然后由主模型完成回答。

## 快速开始

```bash theme={null}
curl https://api.phaseo.app/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-nano",
    "messages": [
      { "role": "user", "content": "Compare these release notes and summarize the breaking changes." }
    ],
    "tools": [
      {
        "type": "phaseo:subagent",
        "parameters": {
          "model": "openai/gpt-5-nano",
          "instructions": "Return concise findings for the main model. Do not address the end user directly.",
          "max_uses": 3,
          "max_completion_tokens": 1200
        }
      }
    ]
  }'
```

## 参数

```json theme={null}
{
  "type": "phaseo:subagent",
  "parameters": {
    "model": "openai/gpt-5-nano",
    "instructions": "You are a fast, focused worker. Complete only the delegated task.",
    "max_uses": 3,
    "max_completion_tokens": 1200,
    "reasoning": { "effort": "low" },
    "temperature": 0.2
  }
}
```

| 参数 | 类型 | 默认值 | 说明 |
| - | - | - | - |
| `model` | string | `openai/gpt-5-nano` | 要调用的工作模型。 |
| `instructions` | string | 面向工作模型的具体指令 | 添加到 Subagent 默认行为中的附加指令。 |
| `max_uses` | integer | `10` | 服务器工具循环中 Subagent 调用次数的上限。 |
| `max_completion_tokens` | integer | 顾问默认值 | 每个工作模型响应的最大输出 Token 数。 |
| `max_tokens` | integer | 顾问默认值 | `max_completion_tokens` 的旧别名。 |
| `reasoning` | object | 提供商默认值 | 支持时传递给工作模型调用的推理配置。 |
| `temperature` | number | 提供商默认值 | 工作模型调用的采样温度。 |

## 工具调用参数

模型通常使用 `task_description` 调用 Subagent：

```json theme={null}
{
  "task_description": "Extract the three highest-risk migration steps from the supplied plan."
}
```

如果模型使用了略有不同的参数名称，Phaseo 也会将 `task`、`prompt` 或 `input` 识别为别名。

## 工具返回内容

Subagent 会以 JSON 形式返回工具结果：

```json theme={null}
{
  "status": "ok",
  "model": "openai/gpt-5-nano",
  "result": "The highest-risk steps are schema migration, traffic cutover, and rollback verification."
}
```

如果工作模型请求无法执行，Phaseo 会返回类似以下的工具错误： `subagent_invalid_request`, `subagent_max_uses_exceeded`, or `subagent_request_failed`.

## 用量和价格

Subagent 调用会增加：

```json theme={null}
{
  "usage": {
    "server_tool_use": {
      "subagent_requests": 1
    }
  }
}
```

工作模型使用的 Token 会计入总用量，并按所选工作模型的价格计费。

## 相关内容

* [Advisor](./advisor.mdx)
* [Fusion](./fusion.mdx)
* [服务器工具](./index.mdx)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.