跳转到主要内容
Session & Event

获取 Session

获取指定会话详情

GET
/api/v1/agentstudio/sessions/{session_id}
cURL
curl --request GET \
  --url 'https://dashscope.aliyuncs.com/api/v1/agentstudio/sessions/{session_id}' \
  --header 'Authorization: Bearer <YOUR_API_KEY>'
{
  "id": "sesn_xxx",
  "type": "session",
  "status": "idle",
  "stop_reason": {
    "type": "requires_action",
    "pending_batch_id": "response_xxx:9f2c...",
    "pending_call_ids": [
      "call_xxx"
    ]
  },
  "agent": {
    "id": "agent_xxx",
    "type": "agent",
    "version": 1,
    "name": "data-analyst",
    "description": null,
    "model": {
      "id": "qwen3-max"
    },
    "system": "你是数据分析专家,使用 pandas 处理 CSV 文件。",
    "tools": []
  },
  "environment_id": "env_xxx",
  "title": "Q3 销售数据分析",
  "metadata": {
    "biz_ticket_id": "1234"
  },
  "archived_at": null,
  "created_at": "2026-05-28T08:23:11Z",
  "updated_at": "2026-05-28T08:23:25Z",
  "request_id": "xxx",
  "environment_variables": {
    "API_BASE_URL": "https://api.example.com",
    "LOG_LEVEL": "info"
  }
}

stop_reason 取值

会话回到 idle 的原因,是一个判别联合。stop_reason 仅在 idle 时用于判断交互状态;running 时为 nullterminated 是终态,接口可能保留此前值,不应依赖或解释。
type说明附加字段
nullrunning,或 idle 刚创建、尚未产生结束原因
end_turn模型主动结束
retries_exhausted重试耗尽
requires_action等待工具审批pending_batch_idpending_call_ids(均非空)
requires_action 时用 pending_batch_id + pending_call_ids 定位当前待裁决调用,再经事件 API 拉取对应的 tool_approval_request。全部审批批次/调用 ID 均非空。 畸形对象校验失败,以下均非法:
示例原因
{}type
{"type":"requires_action"}pending_batch_id / pending_call_ids
{"type":"requires_action","pending_call_ids":[]}pending_call_ids 为空
{"type":"requires_action","pending_batch_id":"","pending_call_ids":["call_xxx"]}空批次 ID
{"type":"requires_action","pending_batch_id":"b","pending_call_ids":[""]}pending_call_ids 含空 item
{"type":"end_turn","pending_batch_id":"b","pending_call_ids":["c"]}终态夹带 pending 字段
requires_action 必须同时含非空 pending_batch_id 与非空 pending_call_ids;其余 type 不夹带 pending 字段。

鉴权

string
header
必填

DashScope API Key

路径参数

string
必填

响应

200-application/json
string

会话 ID,格式 sesn_<ULID>

string

固定为 session

enum<string>

会话状态:idle / running / terminated

idle,running,terminated
end_turn / retries_exhausted

会话回到 idle 的原因(判别联合)。详见 stop_reason 取值。仅 requires_action 携带 pending_batch_id 与非空 pending_call_ids

object

智能体配置完整快照(创建时锁定),含 id/version/name/model/system/tools 等

string

绑定的运行环境 ID

string

会话标题

object

业务自定义元数据

string | null

归档时间,未归档时为 null

string

创建时间,ISO 8601

string

最近更新时间,ISO 8601

string

本次请求的唯一标识

object

会话运行时注入的环境变量