跳转到主要内容
GET /api/v1/cloud/sessions/{session_id}/threads/{thread_id}/stream 以 Server-Sent Events 流式返回一个 thread 的公开事件。 如果 Session 创建时设置了 incremental_streaming_enabled: true,该接口还会输出限定在当前 thread 上的增量 agent 事件。是否开启增量事件不通过每次连接的请求参数控制。

路径参数

参数类型说明
session_idstringsess_ 为前缀的 Session ID
thread_idstringsthr_ 为前缀的 Thread ID

请求头

头部必选说明
AuthorizationBearer $QODER_PAT
Accept使用 text/event-stream
Last-Event-ID提供后从该事件 ID 之后续传。事件 ID 不存在、已被归档、指向非公开内部事件,或不属于该 thread 时返回 400

示例请求

curl -N -X GET "https://api.qoder.com/api/v1/cloud/sessions/sess_019f00000000000000000000000000aa/threads/sthr_019f00000000000000000000000002bb/stream" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Accept: text/event-stream"

流格式

id: evt_019f00000000000000000000000003cc
event: agent.message
data: {"id":"evt_019f00000000000000000000000003cc","type":"agent.message","content":[{"type":"text","text":"Thread response"}],"processed_at":"2026-06-15T08:02:00.000Z"}

id: evt_c3d4e5f6a7b8c9d0
event: session.thread_status_idle
data: {"agent_name":"my-agent","id":"evt_c3d4e5f6a7b8c9d0","processed_at":"2026-06-15T08:02:01.000Z","session_thread_id":"sthr_019f00000000000000000000000002bb","stop_reason":{"type":"end_turn"},"type":"session.thread_status_idle"}
服务端会定期发送 : heartbeat 注释行以保持连接活跃。

增量事件

开启增量流式的 Session 中,thread stream 可能包含当前 thread_id 对应的 agent.message_startagent.content_block_startagent.content_block_deltaagent.content_block_stopagent.message_deltaagent.message_stoptext_deltainput_json_delta 等 delta 细节位于 agent.content_block_delta.delta.type,不是顶层事件类型。详见 Session 数据结构

错误码

HTTP类型触发条件
400invalid_request_errorLast-Event-ID 未能识别该 Session/thread 中的有效公开事件(事件不存在、已被归档、为非公开内部事件,或不属于该 thread)
401authentication_errorPAT 无效或过期
404not_found_errorSession 或 thread 不存在
HTTP 404 Not Found
{
  "type": "error",
  "request_id": "cb80235f-76a2-4ff3-9e28-5aa2da12dc14",
  "error": {
    "type": "not_found_error",
    "message": "Session thread 'sthr_fakefakefake_xxxxxxxxxxxxxxxx' was not found."
  },
  "request_id": "b5822072-f264-48da-9d61-6d48ffb07551"
}
完整错误信封格式见 错误参考

相关

Managed Agents

了解线程事件在多 Agent 协作中的语义。

列出线程事件

分页拉取线程的历史事件。

列出 Session Threads

查看 Session 中的所有线程。