OpenAI Responses 多智能体

2026-11-06 18:48 更新

概览

Multi-agent让模型并行创建、协调子智能体,并综合结果给出最终回答。适合代码库探索、文档制作、实现等可并行分工的复杂任务。

这是Beta功能,来源列明支持GPT-6.1 Sol和全部GPT-5.6模型;启用前应核对模型页。

什么时候使用多智能体

根智能体可将独立任务交给并发子智能体,带来并行执行、独立聚焦的上下文,以及由模型主导的协调:创建、发送补充信息、等待并汇总,而非要求应用自行实现全部编排。

适合探索大型代码库不同部分、比较提案或假设、并行调查资料、实现独立组件或测试、排查多个故障原因,以及尝试不同解题路径。

子智能体可能增加词元消耗。单一顺序推理链、频繁写共享状态、或整体被一个慢外部操作主导的任务,未必受益。

适合多智能体 更适合单智能体
可拆成独立、边界清楚的任务 每步直接依赖前一步
独立上下文有助聚焦 一次短运行即可完成
并行探索可缩短耗时 会竞争同一可变资源
对比独立发现提高覆盖 需要固定、确定的执行图

快速开始

Python与JavaScript示例需要暴露Beta Responses的SDK。HTTP调用client.beta.responses并通过betas传responses_multi_agent=v1;原始HTTP与WebSocket使用请求或连接头OpenAI-Beta: responses_multi_agent=v1。多智能体处于Beta阶段,响应项的数据结构(schema)可能变化。

设置multi_agent.enabled=true,根智能体便可创建子智能体树。它们共享请求的模型和可用工具,通过创建、消息、等待等机制协调,由根智能体汇总最终回答。

使用子智能体审查拉取请求:

来源示例 1(javascript):

// [中文] 使用Beta Responses启用多智能体,最多3个并发子智能体;任务是分别检查PR正确性、安全性和缺失测试,再合并重复发现。
import OpenAI from "openai";

const client = new OpenAI();

async function reviewPullRequest(diff) {
  const response = await client.beta.responses.create({
    model: "gpt-6.1-sol",
    input:
      "Review the pull-request diff below with three agents: one for " +
      "correctness, one for security, and one for missing tests. " +
      "Reconcile duplicate or conflicting findings, then return a " +
      "prioritized review with file and line references.\n\n" +
      `<diff>\n${diff}\n</diff>`,
    multi_agent: {
      enabled: true,
      max_concurrent_subagents: 3,
    },
    betas: ["responses_multi_agent=v1"],
  });

  return response.output
    .flatMap((item) =>
      item.type === "message" &&
      item.agent?.agent_name === "/root" &&
      item.phase === "final_answer"
        ? item.content
        : []
    )
    .filter((part) => part.type === "output_text")
    .map((part) => part.text)
    .join("");
}

来源示例 2(python):

## [中文] 使用Beta Responses启用多智能体,最多3个并发子智能体;任务是分别检查PR正确性、安全性和缺失测试,再合并重复发现。
from openai import OpenAI

client = OpenAI()


def review_pull_request(diff: str) -> str:
    response = client.beta.responses.create(
        model="gpt-6.1-sol",
        input=(
            "Review the pull-request diff below with three agents: one for "
            "correctness, one for security, and one for missing tests. "
            "Reconcile duplicate or conflicting findings, then return a "
            "prioritized review with file and line references.\n\n"
            f"<diff>\n{diff}\n</diff>"
        ),
        multi_agent={
            "enabled": True,
            "max_concurrent_subagents": 3,
        },
        betas=["responses_multi_agent=v1"],
    )

    return "".join(
        part.text
        for item in response.output
        if (
            item.type == "message"
            and item.agent is not None
            and item.agent.agent_name == "/root"
            and item.phase == "final_answer"
        )
        for part in item.content
        if part.type == "output_text"
    )

max_concurrent_subagents限制整棵树同时活跃的子智能体数,包含子、孙及更深层,不包含根智能体。来源没有规定此值固定上界;默认3,适合多数负载。树深度和一次运行创建的子智能体总量也无固定上限。

可用开发者消息规定何时创建子智能体,该消息与系统注入的根/子指令叠加。例如:“只有用户明确要求子智能体、委派或并行工作时才创建”,或“启用主动并行委派,当有助速度或质量时使用”。这些只是文档示例,不构成本地制作任务的操作指令。

多智能体如何工作

Responses向根和子模型提供托管编排动作及使用指令。根名为/root,子智能体采用层级路径:

来源示例 3(text):

/root
├── /root/researcher
├── /root/reviewer
└── /root/reviewer/tester

并发限制覆盖整棵树的活跃轮次;通常用默认3。运行可创建的总数和层级没有固定上限。

平台提供六个托管协作动作,可能显示为multi_agent_call。应用不要执行这些动作或为其提交输出。

动作 用途
spawn_agent 创建子智能体并分配初始任务
send_message 为已有智能体排入消息,不启动新轮次
followup_task 为非根智能体分配工作,并启动或恢复轮次
wait_agent 等待调用方邮箱更新
interrupt_agent 中断另一个智能体的活跃轮次,保留上下文
list_agents 返回智能体树、状态和各自last_task_message

开发者自定义工具与普通模式相同:任意智能体都可能发出function_call,应用需执行并提交匹配的function_call_output。整棵树均可访问请求配置的工具。

在Responses API中使用多智能体

HTTP与WebSocket表现

能力相同,但工具密集或长任务推荐WebSocket。HTTP需等待所有活跃智能体完成或暂停等待客户端函数后,应用再执行待处理调用,通过新请求提交全部输出来恢复。

WebSocket允许函数完成即注入活跃响应,等待该结果的智能体可立即恢复,其他智能体继续运行,减少协调等待和往返请求。

只有并行托管工具(如网页搜索)或少量客户端函数的一次性任务,HTTP可能足够;多数复杂多智能体任务使用WebSocket更有利于端到端延迟。

HTTP函数调用执行

应用、Responses根智能体与三个子智能体之间的HTTP函数调用流程

WebSocket函数调用执行

应用、Responses根智能体与三个子智能体之间的WebSocket函数调用流程

HTTP

示例需Beta SDK。HTTP流式使用client.beta.responses.create并在betas传入标记,以启用Beta类型与补全;Python类型注解使用openai.types.beta中的响应项类型。

来源示例 4(javascript):

// [中文] HTTP流式收集所有待处理function_call,执行示例get_proposal,再用新请求提交结果;alpha约6周中风险,beta约8周低风险。
import OpenAI from "openai";

const client = new OpenAI();
const ROOT = "/root";
const proposals = {
  alpha: { estimated_weeks: 6, risk: "medium" },
  beta: { estimated_weeks: 8, risk: "low" },
};

const tools = [
  {
    type: "function",
    name: "get_proposal",
    description:
      "Return details for a proposal that the agents should compare.",
    parameters: {
      type: "object",
      properties: {
        proposal: {
          type: "string",
          enum: ["alpha", "beta"],
        },
      },
      required: ["proposal"],
      additionalProperties: false,
    },
    strict: true,
  },
];

const history = [
  {
    role: "user",
    content: "Compare proposal alpha and proposal beta.",
  },
];

function agentName(item) {
  return item.agent?.agent_name ?? ROOT;
}

function processToolCall(name, argumentsJson) {
  if (name !== "get_proposal") {
    throw new Error(`Unknown tool: ${name}`);
  }
  const { proposal } = JSON.parse(argumentsJson);

  return JSON.stringify(proposals[proposal]);
}

while (true) {
  const outputItems = [];
  const pendingCalls = [];
  const itemAgents = new Map();

  const stream = await client.beta.responses.create({
    model: "gpt-6.1-sol",
    // Beta output items can be replayed as input on the next request.
    input: history,
    tools,
    store: false,
    multi_agent: {
      enabled: true,
      max_concurrent_subagents: 3,
    },
    stream: true,
    betas: ["responses_multi_agent=v1"],
  });

  for await (const event of stream) {
    if (event.type === "response.output_item.added") {
      itemAgents.set(event.output_index, agentName(event.item));
    } else if (event.type === "response.output_text.delta") {
      const agent = itemAgents.get(event.output_index) ?? ROOT;
      const destination = agent === ROOT ? process.stdout : process.stderr;
      destination.write(
        agent === ROOT ? event.delta : `[${agent}] ${event.delta}`
      );
    } else if (event.type === "response.output_item.done") {
      outputItems.push(event.item);
      if (event.item.type === "function_call") {
        pendingCalls.push(event.item);
      }
    } else if (event.type === "response.completed") {
      console.error("\nUsage:", event.response.usage);
      break;
    } else if (
      event.type === "error" ||
      event.type === "response.failed" ||
      event.type === "response.incomplete"
    ) {
      throw new Error(JSON.stringify(event));
    }
  }

  history.push(...outputItems);
  for (const call of pendingCalls) {
    history.push({
      type: "function_call_output",
      call_id: call.call_id,
      output: processToolCall(call.name, call.arguments),
    });
  }

  if (pendingCalls.length === 0) break;
}

来源示例 5(python):

## [中文] HTTP流式收集所有待处理function_call,执行示例get_proposal,再用新请求提交结果;alpha约6周中风险,beta约8周低风险。
## [中文] 本轮明确要求两个子智能体分别取得alpha/beta方案,再比较结果;这是示例输入,不会在本地运行。
from __future__ import annotations

import json
import sys

from openai import OpenAI
from openai.types.beta import BetaResponseOutputItem

client = OpenAI()
ROOT = "/root"
PROPOSALS = {
    "alpha": {"estimated_weeks": 6, "risk": "medium"},
    "beta": {"estimated_weeks": 8, "risk": "low"},
}
tools = [
    {
        "type": "function",
        "name": "get_proposal",
        "description": "Return details for a proposal that the agents should compare.",
        "parameters": {
            "type": "object",
            "properties": {
                "proposal": {
                    "type": "string",
                    "enum": ["alpha", "beta"],
                }
            },
            "required": ["proposal"],
            "additionalProperties": False,
        },
        "strict": True,
    }
]
history = [
    {
        "role": "user",
        "content": (
            "Use two subagents, one for proposal alpha and one for proposal beta. "
            "Have each call get_proposal, then compare their findings."
        ),
    }
]


def agent_name(item: BetaResponseOutputItem) -> str:
    return item.agent.agent_name if item.agent else ROOT


def render_to_user(delta: str) -> None:
    print(delta, end="", flush=True)


def log_subagent_text(agent: str, delta: str) -> None:
    print(f"[{agent}] {delta}", end="", file=sys.stderr, flush=True)


def process_tool_call(name: str, arguments: str) -> str:
    if name != "get_proposal":
        raise ValueError(f"Unknown tool: {name}")
    parsed_arguments = json.loads(arguments)
    return json.dumps(PROPOSALS[parsed_arguments["proposal"]])


while True:
    output_items = []
    pending_calls = []
    item_agents: dict[int, str] = {}

    stream = client.beta.responses.create(
        model="gpt-6.1-sol",
        input=history,
        tools=tools,
        store=False,
        multi_agent={
            "enabled": True,
            "max_concurrent_subagents": 3,
        },
        stream=True,
        betas=["responses_multi_agent=v1"],
    )
    for event in stream:
        if event.type == "response.output_item.added":
            item_agents[event.output_index] = agent_name(event.item)
        elif event.type == "response.output_text.delta":
            agent = item_agents.get(event.output_index, ROOT)
            if agent == ROOT:
                render_to_user(event.delta)
            else:
                log_subagent_text(agent, event.delta)
        elif event.type == "response.output_item.done":
            output_items.append(event.item)
            if event.item.type == "function_call":
                # Handle function calls from both the root agent and subagents.
                pending_calls.append(event.item)
        elif event.type == "response.completed":
            print(f"\nUsage: {event.response.usage}", file=sys.stderr)
            break
        elif event.type in {
            "error",
            "response.failed",
            "response.incomplete",
        }:
            raise RuntimeError(event)

    history.extend(output_items)

    for call in pending_calls:
        history.append(
            {
                "type": "function_call_output",
                "call_id": call.call_id,
                "output": process_tool_call(call.name, call.arguments),
            }
        )

    if not pending_calls:
        break

一个或多个智能体调用自定义函数时,执行所有待处理调用,并在后续请求中提交输出。

WebSocket

应用执行函数后,以response.inject把结果交给活跃响应,不必等整次多智能体响应完成。

来源示例 6(json):

{
  "type": "response.inject",
  "response_id": "resp_123",
  "input": [
    {
      "type": "function_call_output",
      "call_id": "call_123",
      "output": "{\"temperature\":72}"
    }
  ]
}

合法请求会得到response.inject.created(校验并接受)或response.inject.failed(未注入,应检查error.code)。

来源示例 7(json):

{
  "type": "response.inject.created",
  "sequence_number": 42,
  "response_id": "resp_123"
}

来源示例 8(json):

{
  "type": "response.inject.failed",
  "sequence_number": 43,
  "response_id": "resp_123",
  "input": [
    {
      "type": "function_call_output",
      "call_id": "call_123",
      "output": "{\"temperature\":72}"
    }
  ],
  "error": {
    "code": "response_already_completed",
    "message": "Response 'resp_123' has already completed."
  }
}

不符合response.inject模式的请求会收到通用400错误,WebSocket被关闭;应修正后重新连接。

Python用client.beta.responses.connect,TypeScript用ResponsesWS。连接头传Beta标记,连接器目前不像HTTP流式那样接受betas参数。

保存response.created中的响应ID,每次注入都带上。注入后继续读取,直到响应完成,且每次注入都有created或failed确认。

来源示例 9(javascript):

// [中文] WebSocket以response.inject注入工具结果,持续读取直到响应结束且每次注入都已确认。示例比较alpha、beta提案。
import OpenAI from "openai";

import { ResponsesWS } from "openai/resources/beta/responses/ws";

const client = new OpenAI();
const proposals = {
  alpha: { estimated_weeks: 6, risk: "medium" },
  beta: { estimated_weeks: 8, risk: "low" },
};
const tools = [
  {
    type: "function",
    name: "get_proposal",
    description:
      "Return details for a proposal that the agents should compare.",
    parameters: {
      type: "object",
      properties: {
        proposal: {
          type: "string",
          enum: ["alpha", "beta"],
        },
      },
      required: ["proposal"],
      additionalProperties: false,
    },
    strict: true,
  },
];

function processToolCall(name, argumentsJson) {
  if (name !== "get_proposal") {
    throw new Error(`Unknown tool: ${name}`);
  }
  const { proposal } = JSON.parse(argumentsJson);

  return JSON.stringify(proposals[proposal]);
}

async function runMultiAgent(ws) {
  let previousResponseId;
  let pendingInput = [
    { role: "user", content: process.argv.slice(2).join(" ") },
  ];

  while (pendingInput.length > 0) {
    ws.send({
      type: "response.create",
      model: "gpt-6.1-sol",
      store: true,
      multi_agent: {
        enabled: true,
        max_concurrent_subagents: 3,
      },
      tools,
      input: pendingInput,
      previous_response_id: previousResponseId,
    });

    const nextInput = [];
    let completedResponse;
    let responseId;
    let pendingInjections = 0;

    for await (const message of ws) {
      if (message.type === "error") throw message.error;
      if (message.type !== "message") continue;

      const event = message.message;
      if (event.type === "response.created") {
        responseId = event.response.id;
      } else if (
        event.type === "response.output_item.done" &&
        event.item.type === "function_call"
      ) {
        if (!responseId) {
          throw new Error("Received a function call before response.created");
        }
        pendingInjections += 1;
        ws.send({
          type: "response.inject",
          response_id: responseId,
          input: [
            {
              type: "function_call_output",
              call_id: event.item.call_id,
              output: processToolCall(event.item.name, event.item.arguments),
            },
          ],
        });
      } else if (event.type === "response.inject.created") {
        pendingInjections -= 1;
      } else if (event.type === "response.inject.failed") {
        pendingInjections -= 1;
        if (event.error.code !== "response_already_completed") {
          throw new Error(JSON.stringify(event.error));
        }
        nextInput.push(...event.input);
      } else if (event.type === "response.completed") {
        completedResponse = event.response;
      } else if (
        event.type === "error" ||
        event.type === "response.failed" ||
        event.type === "response.incomplete"
      ) {
        throw new Error(JSON.stringify(event));
      }

      if (completedResponse && pendingInjections === 0) break;
    }

    if (!completedResponse) {
      throw new Error("Connection ended before response.completed");
    }
    if (pendingInjections !== 0) {
      throw new Error("Connection ended with unacknowledged tool results");
    }
    if (nextInput.length === 0) return completedResponse;

    previousResponseId = completedResponse.id;
    pendingInput = nextInput;
  }
}

const ws = new ResponsesWS(client, {
  headers: { "OpenAI-Beta": "responses_multi_agent=v1" },
});

try {
  const response = await runMultiAgent(ws);
  const text = response.output
    .flatMap((item) =>
      item.type === "message" &&
      item.agent?.agent_name === "/root" &&
      item.phase === "final_answer"
        ? item.content
        : []
    )
    .filter((part) => part.type === "output_text")
    .map((part) => part.text)
    .join("");
  console.log(text);
} finally {
  ws.close();
}

来源示例 10(python):

## [中文] WebSocket以response.inject注入工具结果,持续读取直到响应结束且每次注入都已确认。示例比较alpha、beta提案。
from __future__ import annotations

import json

from openai import OpenAI

client = OpenAI()
PROPOSALS = {
    "alpha": {"estimated_weeks": 6, "risk": "medium"},
    "beta": {"estimated_weeks": 8, "risk": "low"},
}
tools = [
    {
        "type": "function",
        "name": "get_proposal",
        "description": "Return details for a proposal that the agents should compare.",
        "parameters": {
            "type": "object",
            "properties": {
                "proposal": {
                    "type": "string",
                    "enum": ["alpha", "beta"],
                }
            },
            "required": ["proposal"],
            "additionalProperties": False,
        },
        "strict": True,
    }
]


def process_tool_call(name: str, arguments: str) -> str:
    if name != "get_proposal":
        raise ValueError(f"Unknown tool: {name}")
    parsed_arguments = json.loads(arguments)
    return json.dumps(PROPOSALS[parsed_arguments["proposal"]])


def run_multi_agent(connection):
    previous_response_id: str | None = None
    pending_input: list[dict[str, object]] = [{"role": "user", "content": input()}]

    while pending_input:
        request = {
            "type": "response.create",
            "model": "gpt-6.1-sol",
            "store": True,
            "multi_agent": {"enabled": True},
            "tools": tools,
            "input": pending_input,
        }
        if previous_response_id is not None:
            request["previous_response_id"] = previous_response_id

        connection.send(request)

        next_input: list[dict[str, object]] = []
        completed_response = None
        response_id: str | None = None
        pending_injections = 0

        for event in connection:
            event_type = event.type

            if event_type == "response.created":
                response_id = event.response.id

            elif event_type == "response.output_item.done":
                item = event.item

                if item.type == "function_call":
                    if response_id is None:
                        raise RuntimeError(
                            "Received a function call before response.created"
                        )

                    output = {
                        "type": "function_call_output",
                        "call_id": item.call_id,
                        "output": process_tool_call(item.name, item.arguments),
                    }
                    pending_injections += 1

                    connection.send(
                        {
                            "type": "response.inject",
                            "response_id": response_id,
                            "input": [output],
                        }
                    )

            elif event_type == "response.inject.created":
                pending_injections -= 1

            elif event_type == "response.inject.failed":
                pending_injections -= 1

                if event.error.code != "response_already_completed":
                    raise RuntimeError(event.error)

                next_input.extend(item.model_dump(mode="json") for item in event.input)

            elif event_type == "response.completed":
                completed_response = event.response

            elif event_type in {
                "error",
                "response.failed",
                "response.incomplete",
            }:
                raise RuntimeError(event)

            if completed_response is not None and pending_injections == 0:
                break

        if completed_response is None:
            raise RuntimeError("Connection ended before response.completed")
        if pending_injections:
            raise RuntimeError("Connection ended with unacknowledged tool results")

        if not next_input:
            return completed_response

        previous_response_id = completed_response.id
        pending_input = next_input


with client.beta.responses.connect(
    extra_headers={"OpenAI-Beta": "responses_multi_agent=v1"},
) as connection:
    response = run_multi_agent(connection)
    print(
        "".join(
            part.text
            for item in response.output
            if (
                item.type == "message"
                and item.agent is not None
                and item.agent.agent_name == "/root"
                and item.phase == "final_answer"
            )
            for part in item.content
            if part.type == "output_text"
        )
    )

处理确认:created表示结果已加入,继续读取;failed若为response_already_completed,取失败事件返回的input,用新response.create从已完成响应继续;若为response_not_found,检查是否使用创建事件中的正确ID。

一次多智能体运行可跨多个Responses请求:HTTP用新请求续接工具结果,WebSocket则注入活跃响应。

新增多智能体输出项

  • multi_agent_call:记录托管动作,如创建子智能体。
  • multi_agent_call_output:托管动作的执行结果。
  • agent_message:智能体间的加密消息。

call_id关联调用与输出。各项带agent属性;对agent_message,agent.agent_name表示接收方,用author与recipient判断方向。

应用收到托管动作时不要当函数执行,也不要回传结果;平台会执行并提供输出。需要重放或追踪时,两种项目都要保留。

来源示例 11(json):

[
  {
    "type": "multi_agent_call",
    "id": "mac_123",
    "call_id": "call_spawn_a",
    "action": "spawn_agent",
    "arguments": "{\"task_name\":\"agent_a\",\"fork_turns\":\"all\",\"message\":\"enc_...\"}",
    "agent": { "agent_name": "/root" }
  },
  {
    "type": "multi_agent_call_output",
    "id": "maco_123",
    "call_id": "call_spawn_a",
    "action": "spawn_agent",
    "output": [
      {
        "type": "output_text",
        "text": "{\"task_name\":\"/root/agent_a\"}",
        "annotations": [],
        "logprobs": []
      }
    ],
    "agent": { "agent_name": "/root" }
  },
  {
    "type": "agent_message",
    "id": "amsg_123",
    "author": "/root/agent_a",
    "recipient": "/root",
    "content": [
      {
        "type": "encrypted_content",
        "encrypted_content": "enc_..."
      }
    ],
    "agent": { "agent_name": "/root" }
  }
]

属于特定智能体的SSE事件有顶层agent;消息事件中它指接收方。response.created、response.completed等生命周期事件描述整体响应,不带该智能体属性。

来源示例 12(json):

{
  "type": "response.output_item.done",
  "agent": { "agent_name": "/root" },
  "item": {
    "type": "agent_message",
    "id": "amsg_123",
    "author": "/root/agent_a",
    "recipient": "/root",
    "content": [
      {
        "type": "encrypted_content",
        "encrypted_content": "enc_..."
      }
    ],
    "agent": { "agent_name": "/root" }
  }
}

限制

  1. 启用多智能体时不支持/responses/compact;会隐式启用自动服务端压缩,即使未配置context_management。根与每个子智能体独立压缩。可通过显式压缩阈值配置覆盖默认阈值。
  2. 不支持reasoning.summary。
  3. 不支持max_tool_calls。
  4. 并发子智能体默认3,来源推荐保持此值。

提示词指导

启用后,平台会为根和子智能体追加新的开发者指令,不能编辑或删除;自有开发者指令应作为补充。以下是来源提供的指令文本,仅供理解API行为。

根智能体

来源示例 13(text):

本例中文译文:你是/root,是协作实现用户目标的主智能体。开始轮次时你处于活跃状态。可以创建子智能体处理子任务,子智能体也可继续创建;所有智能体能力相同,使用相同工具。spawn_agent创建并分配初始任务;followup_task给已有智能体新任务并触发轮次;send_message向运行中的智能体发消息但不触发新轮次。用fork_turns决定传递多少上下文。

接收消息包含Message Type(MESSAGE或FINAL_ANSWER)、Task name(接收任务)、Sender(发送者)、Payload(正文),也可能写作to=/root。并发槽位为{max_concurrent_subagents + 1},包含根智能体本人。以上是来源API注入指令的译文。

You are /root, the primary agent in a team of agents collaborating to fulfill the user's goals.

At the start of your turn, you are the active agent. You can spawn sub-agents to handle subtasks, and those sub-agents can spawn their own sub-agents. All agents in the team, including the agents that you can assign tasks to, are equally intelligent and capable, and have access to the same set of tools.

You can use spawn_agent to create a new agent, followup_task to give an existing agent a new task and trigger a turn, and send_message to pass a message to a running agent without triggering a turn. Child agents can also spawn their own sub-agents. You can decide how much context you want to propagate to your sub-agents with the fork_turns parameter.

You will receive messages in the form:

    Message Type: MESSAGE | FINAL_ANSWER
    Task name: <recipient>
    Sender: <author>
    Payload:
    <payload text>
They may be addressed as to=/root

There are {max_concurrent_subagents + 1} available concurrency slots, meaning that up to {max_concurrent_subagents + 1} agents can be active at once, including you.

子智能体

来源示例 14(text):

本例中文译文:你是协作团队的一员。可以创建子智能体,它们也可创建后代;所有成员能力和工具相同。spawn_agent创建并分派初始任务;followup_task分配新任务并触发轮次;send_message发送消息。你在final通道给出的内容会立即回传父智能体。

消息格式含NEW_TASK、MESSAGE或FINAL_ANSWER类型,以及接收任务、发送者和正文;to=/root/...表明你的层级身份。并发槽位为{max_concurrent_subagents + 1},包含自己。以上仅为来源指令译文,不改变本地制作权限。

You are an agent in a team of agents collaborating to complete a task.

You can spawn sub-agents to handle subtasks, and those sub-agents can spawn their own sub-agents. All agents in the team, including the agents that you can assign tasks to, are equally intelligent and capable, and have access to the same set of tools.

You can use spawn_agent to create a new agent, followup_task to give an existing agent a new task and trigger a turn, and send_message to pass a message to a running agent. Child agents can also spawn their own sub-agents.

When you provide a response in the final channel, that content is immediately delivered back to your parent agent.

You will receive messages in the form:

    Message Type: NEW_TASK | MESSAGE | FINAL_ANSWER
    Task name: <recipient>
    Sender: <author>
    Payload:
    <payload text>
You may also see them addressed as to=/root/..., which indicates your identity is /root/...

There are {max_concurrent_subagents + 1} available concurrency slots, meaning that up to {max_concurrent_subagents + 1} agents can be active at once, including you.

相关指南

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号