跳转到内容
EN

列出会话待处理请求(扩展)

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET/agent/v1/sessions/{session_id}/requests● 支持

请求参数

  • session_idstring必填

    path: Session id from session creation or listing.

返回

200

仅在 /agent/v1 提供。会话停在 session.status_idle 且 stop_reason 为 requires_action 时,用它读等的是什么,不必回放事件流。返回 { data: Request[] },按 create_time 升序,没有待处理项就是空数组,不分页。每项含 id(待决工具调用的 id)、object(request)、kind(恒为 approval:等待授权的工具;question 仅为兼容保留,不会返回)、status(pending)、tool_name、input(与 agent.tool_use 事件里的 input 相同)、create_time、expire_time。答复方式不变:对这个 id 发 user.tool_confirmation 事件。expire_time 只在会话没有协作模式且 requests-v1 发布开启时有值(create_time 加 24 小时,到期视为拒绝),否则为 null。已答复、已过期、被新消息取代的请求不再列出;自定义工具的待决结果(user.custom_tool_result)不在此列。会话不存在或不可见返回 404。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

请求示例

curl
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
curl https://api.deepraxis.com/agent/v1/sessions/sesn_123/requests \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
Python
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
import requests

opts = dict(
    base_url="https://api.deepraxis.com/agent",
    api_key="$PRAXIS_API_KEY",
)

# /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.get(
    f"{opts['base_url']}/v1/sessions/sesn_123/requests",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
)
print(resp.status_code, resp.json())
TypeScript
// 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
const opts = {
  baseURL: "https://api.deepraxis.com/agent",
  apiKey: "$PRAXIS_API_KEY",
};

// /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/v1/sessions/sesn_123/requests`, {
  headers: { Authorization: `Bearer ${opts.apiKey}` },
});
console.log(resp.status, await resp.json());

响应示例 200

{
  "data": [
    {
      "id": "toolu_13fbe42c3c3d48f4b55bef4f",
      "object": "request",
      "status": "pending",
      "kind": "question",
      "tool_name": "ask_user_question",
      "input": {
        "questions": [
          {
            "question": "会议室订在哪一天?",
            "header": "日期",
            "options": [
              {
                "label": "今天 11月14日(周六)",
                "description": "当天使用"
              },
              {
                "label": "明天 11月15日(周日)",
                "description": "次日使用"
              },
              {
                "label": "下周一 11月16日",
                "description": "工作日使用"
              }
            ]
          },
          {
            "question": "希望什么时间段开始?",
            "header": "时间",
            "options": [
              {
                "label": "上午 9:00",
                "description": "上午时段"
              },
              {
                "label": "上午 10:00",
                "description": "上午时段"
              },
              {
                "label": "下午 14:00",
                "description": "下午时段"
              },
              {
                "label": "下午 16:00",
                "description": "傍晚时段"
              }
            ]
          },
          {
            "question": "需要多长时间?",
            "header": "时长",
            "options": [
              {
                "label": "30 分钟",
                "description": "短会"
              },
              {
                "label": "1 小时",
                "description": "常规会议"
              },
              {
                "label": "2 小时",
                "description": "较长会议"
              },
              {
                "label": "半天",
                "description": "约 3-4 小时"
              }
            ]
          },
          {
            "question": "参会人数大概多少?",
            "header": "人数",
            "options": [
              {
                "label": "2-4 人",
                "description": "小会议室"
              },
              {
                "label": "5-8 人",
                "description": "中型会议室"
              },
              {
                "label": "9-15 人",
                "description": "大会议室"
              },
              {
                "label": "16 人以上",
                "description": "培训室/大会议室"
              }
            ]
          }
        ]
      },
      "create_time": "2026-11-14T16:27:00.504Z",
      "expire_time": "2026-11-15T16:27:00.504Z"
    }
  ]
}

响应

HTTP 200

The requests this session waits on

application/json

名称 类型 说明
data array<object> The requests the session waits on, oldest first; empty when it waits on nothing.
data[].id string The pending tool call's id (the tool_use id on the agent.tool_use event); answer it with a user.tool_confirmation event carrying this id as tool_use_id.
data[].object string Object type, always request.
data[].kind string Always approval: a tool waits for permission. question is kept for compatibility and is never returned: the agent asks with a card or in words and the person answers with a message.
data[].status string Always pending: answered, expired and superseded requests are not listed.
data[].tool_name string The tool the agent called, such as bash.
data[].input any The tool call's input exactly as the agent.tool_use event shows it: the tool's arguments.
data[].create_time string When the call became pending, RFC 3339; the time of its agent.tool_use event.
data[].expire_time string | null When the request expires and counts as declined, RFC 3339; null when it does not expire, which is every session that runs a collaboration mode and every session while the requests-v1 release is off.