列出事件

更新时间:
复制为 MD 格式

获取 Session 中的事件列表,按时间正序排列。支持游标分页。

请求头

头部

必选

说明

Authorization

Bearer <PAT>

路径参数

参数

类型

必选

说明

session_id

string

Session ID(sess_ 前缀)

查询参数

参数

类型

必选

说明

limit

integer

返回数量上限,默认 20

after_id

string

游标分页:返回该事件 ID 之后的记录

before_id

string

游标分页:返回该事件 ID 之前的记录

order

string

排序方向:asc(默认,时间正序)或 desc(时间倒序)

完整分页规范详见 分页

示例请求

curl -X GET "https://api.qoder.com.cn/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/events?limit=5" \
  -H "Authorization: Bearer $QODER_PAT"

示例响应

HTTP 200 OK

{
  "data": [
    {
      "id": "evt_019e392c0d787cfaa21bda98e06cd913",
      "type": "user.message",
      "content": "你好,这是一个测试消息",
      "session_id": "sess_019e392c0d1e74e095d21ea4c6b41def",
      "turn_id": "turn_019e392c0d787ceea6bb62943f9ac3ec",
      "schema_version": "1.0",
      "created_at": "2026-05-18T03:40:48.888851795Z",
      "processed_at": "2026-05-18T03:40:48.888851795Z"
    },
    {
      "id": "evt_771c1195bcbd4a07834d4ed4dd6450ca",
      "type": "session.status_running",
      "session_id": "sess_019e392c0d1e74e095d21ea4c6b41def",
      "turn_id": "turn_019e392c0d787ceea6bb62943f9ac3ec",
      "schema_version": "1.0",
      "created_at": "2026-05-18T03:40:50.321Z",
      "processed_at": "2026-05-18T03:40:50.321Z"
    }
  ],
  "first_id": "evt_019e392c0d787cfaa21bda98e06cd913",
  "last_id": "evt_771c1195bcbd4a07834d4ed4dd6450ca",
  "has_more": true
}

事件类型参考

type

说明

特有字段

user.message

用户消息

content (string)

agent.tool_use

Agent 发起工具调用

tool_name, name, tool_input, tool_use_id, requires_confirmation

agent.tool_result

工具执行结果

tool_use_id, content (ContentBlock[]), is_error

agent.message

Agent 回复

content (ContentBlock[])

agent.thinking

Agent 思考

-

session.status_running

会话开始执行

-

session.status_idle

会话回到空闲

usage, status, stop_reason

session.error

会话执行错误

error, details, retry_status

span.model_request_start

模型请求开始

-

span.model_request_end

模型请求结束

-

terminated

执行终止

-

agent.messagecontent 格式:

{
  "content": [
    {
      "type": "text",
      "text": "Agent 的回复文本内容"
    }
  ]
}

session.status_idle 的额外字段:

{
  "type": "session.status_idle",
  "status": "idle",
  "usage": {
    "input_tokens": 150,
    "output_tokens": 42,
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0
  },
  "stop_reason": {
    "type": "end_turn"
  }
}

session.error 格式:

{
  "type": "session.error",
  "error": {
    "message": "The operation was aborted due to timeout",
    "type": "unknown_error"
  },
  "details": {
    "message": "The operation was aborted due to timeout",
    "name": "TimeoutError"
  },
  "retry_status": {
    "type": "exhausted"
  }
}

响应字段

字段

类型

说明

data

array

事件对象列表

first_id

string

当前页第一条记录的 ID

last_id

string

当前页最后一条记录的 ID

has_more

boolean

是否还有更多记录

错误码

HTTP

type

触发条件

401

authentication_error

PAT 无效或过期

404

not_found_error

Session 不存在

完整错误信封说明详见 错误参考