GET /v1/sessions/{session_id}/threads/{thread_id}/stream
Server-Sent Events (SSE) で特定の Session スレッドのイベントをリアルタイムに受信します。接続が確立されると、サーバーはそのスレッドの完全なイベント履歴をプッシュし、新しいイベントが発生するたびに継続的にストリーミングします。そのスレッドに属するイベントのみがストリーミングされます。
ヘッダー
| ヘッダー | 必須 | 説明 |
|---|---|---|
Authorization | はい | Bearer <PAT> |
Accept | 推奨 | text/event-stream |
Last-Event-ID | いいえ | このイベント ID 以降から再開。ID は現在のスレッドに属している必要があります |
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
session_id | string | はい | Session ID(sess_ プレフィックス) |
thread_id | string | はい | Thread ID(sthr_ プレフィックス) |
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
type | string | いいえ | イベントタイプでフィルタリング。カンマ区切りの値をサポート |
types[] | string | いいえ | type の配列形式の代替 |
リクエスト例
レスポンス例
HTTP 200 OKContent-Type: text/event-stream
各イベントは SSE 標準形式に従います。すべてのイベントには session_thread_id フィールドが含まれます:
子スレッドが作成された:
スレッドイベントタイプ
Session レベルのイベントタイプに加えて、以下のスレッド固有イベントタイプが利用可能です:| event (SSE field) | 説明 |
|---|---|
session.thread_created | 新しい子スレッドが作成された。parent_thread_id、agent_id、agent_version、agent_name、role、created_by_tool_use_id を含む |
session.thread_status_running | スレッドが実行を開始した。agent_name、status を含む |
session.thread_status_idle | スレッドがアイドルに戻った。status、stop_reason を含む |
session.thread_status_terminated | スレッドがアーカイブまたは終了された。status、stop_reason を含む |
agent.thread_message_sent | スレッド間メッセージが送信された。direction、content、from_session_thread_id、to_session_thread_id を含む |
agent.thread_message_received | スレッド間メッセージが受信された。direction、content、is_error、from_session_thread_id、to_session_thread_id を含む |
session_thread_id フィールドが含まれます。Session レベルのイベントストリーム(/sessions/{id}/events/stream)はすべてのスレッドのイベントを含み、スレッドレベルのイベントストリームは指定されたスレッドのイベントのみを含みます。
エラーコード
| HTTP | type | トリガー条件 |
|---|---|---|
| 400 | invalid_request_error | Last-Event-ID がこのスレッドに属していない |
| 401 | authentication_error | PAT が無効または期限切れ |
| 404 | not_found_error | Session または Thread が存在しない |
関連項目
Managed Agents
Coordinator と子スレッドのイベントモデルを確認します。
スレッドイベント一覧
REST でスレッドイベント履歴をページ単位に取得します。
Session Threads 一覧
Session 内のすべてのスレッドとそのステータスを取得します。
Event オブジェクト
イベントオブジェクトのフィールド定義を参照します。