OpenAI 列出会话子智能体

2026-11-18 18:02 更新

get /agents/sessions/{session_id}/subagents

列出会话中的子智能体,包括嵌套及已关闭的子智能体。参见子智能体工作流。

路径参数

  • session_id: string

会话 ID。

minLength: 0, maxLength: 1048576

查询参数

  • after: optional string

按选定顺序返回此资源 ID 之后的资源。

minLength: 0, maxLength: 1048576

  • limit: optional integer (default: 20)

返回资源的最大数量,范围为 1 至 100,默认为 20。

format: int64, minimum: 1, maximum: 100

  • order: optional "asc" or "desc" (default: "desc")

返回资源的排序方式,默认为 desc。

  • "asc"

按升序返回资源。

  • "desc"

按降序返回资源。

返回值

  • data: array of Subagent

本页返回的资源,按指定顺序排列。

minItems: 0, maxItems: 2000

  • id: string

子智能体 ID。

minLength: 0

  • closed_at: integer or null

子智能体关闭时的 Unix 时间戳,单位为秒。子智能体活动期间为 null,恢复运行后也适用。

format: int64

  • instructions: array of AgentContent or null

初始任务内容。无法取得时为 null。仅能提供预览时,文本可包含图像或音频的占位符。

minItems: 0, maxItems: 2000

  • OutputText object { text, type }

智能体生成的一段文本内容。

  • text: string

智能体生成的文本。

minLength: 0

  • type: "output_text" (default: "output_text")

内容类型,固定为 output_text。

  • "output_text"

  • EncryptedContent object { encrypted_content, type }

智能体之间交换的加密内容。

  • encrypted_content: string

加密内容载荷。

minLength: 0

  • type: "encrypted_content" (default: "encrypted_content")

内容类型,固定为 encrypted_content。

  • "encrypted_content"

  • name: string or null

运行器分配的昵称。无法取得时为 null。

minLength: 0

  • object: "agent.session.subagent" (default: "agent.session.subagent")

对象类型,固定为 agent.session.subagent。

  • "agent.session.subagent"

  • opened_at: integer

子智能体首次打开时的 Unix 时间戳,单位为秒。恢复运行时此值保持不变。

format: int64

  • parent_agent_id: string

创建此子智能体的智能体 ID。

minLength: 0

  • session_id: string

所属会话的 ID。

minLength: 0

  • status: "active" or "closed"

子智能体当前的状态。

  • "active"

子智能体仍可使用,包括在两轮之间空闲时。

  • "closed"

子智能体已关闭。

  • first_id: string or null

data 中第一项的资源 ID。当前页为空时为 null。

minLength: 0

  • has_more: boolean

当前页之后是否还有可获取的资源。

  • last_id: string or null

data 中最后一项的资源 ID。当前页为空时为 null。翻页时,将它作为 after 传入,并保持排序和筛选条件一致。

minLength: 0

  • object: "list" (default: "list")

对象类型,恒为 list。

  • "list"

示例

## 从环境变量读取 API 密钥。
## 将 SESSION_ID 设置为目标会话的 ID。
curl https://api.openai.com/v1/agents/sessions/$SESSION_ID/subagents \
    -H 'OpenAI-Beta: agents=v1' \
    -H "Authorization: Bearer $OPENAI_API_KEY"

200 响应示例

字段名、类型值和示例标识均按接口定义保留。

{
  "data": [
    {
      "id": "id",
      "closed_at": 0,
      "instructions": [
        {
          "text": "text",
          "type": "output_text"
        }
      ],
      "name": "name",
      "object": "agent.session.subagent",
      "opened_at": 0,
      "parent_agent_id": "parent_agent_id",
      "session_id": "session_id",
      "status": "active"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号