分页列出会话,按 created_at 倒序返回。支持按智能体、状态、创建时间范围过滤。
前提
已完成 Endpoint 与鉴权配置,详见API 总览与认证。
接口
GET /sessions
Query 参数
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
agent_id | string | — | 按智能体过滤 |
statuses[] | string | — | 多状态过滤,可重复传入。如 ?statuses[]=idle&statuses[]=running |
created_at[gte] / created_at[lte] | string | — | 创建时间范围,ISO 8601 |
limit | int | 20 | 每页数量,最大 100 |
page | string | — | 首次不传,后续传上一次响应的 next_page |
请求示例
响应示例
data(Session 对象数组)与 next_page(下一页游标)。Session 对象字段如下:
Session 对象字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 会话 ID,格式 sesn_<ULID> |
type | string | 固定为 session |
status | string | 会话状态:idle / running / terminated |
stop_reason | object / null | 会话回到 idle 的原因,判别联合。null / {"type":"end_turn"} / {"type":"retries_exhausted"} / {"type":"requires_action","pending_batch_id":"...","pending_call_ids":[...]}。仅在 status=idle 时用于判断交互状态 |
agent | object | 智能体配置快照,含 id / version / name / model / system / tools 等 |
environment_id | string | 绑定的运行环境 ID |
title / metadata | string / object | 会话标题与业务自定义元数据 |
archived_at | string / null | 归档时间,未归档时为 null |
created_at / updated_at | string | 创建 / 最近更新时间,ISO 8601 |
environment_variables | object | 会话运行时注入的环境变量,字符串键值对,沙箱代码中可直接按名读取 |