WikifitaGitHub live67e8de5
pesquisa · openai-research/response-sse-real

Chat Submode SSE — Real Delta Protocol with Message Markers

The captured response stream of /f/conversation — delta v1, infrastructure events (resume token, input echo, message markers) and assistant/tool messages

Baixar raw

Chat Submode SSE — Real Captured Protocol

Part of openai-research. Source: bezetacil 004-response-sse.js capturing the raw SSE body of /f/conversation (2026-08-26, multiple real messages).

Stream envelope

The response is standard SSE blocks: event: <name> + data: <json>. Some events carry a named event: line; infrastructure events are data-only (no event: line) — the parsed {event: undefined, data: {type: …}}.

Named events

delta_encoding — v1

event: delta_encoding
data: "v1"

First event of every stream. The delta encoding version.

delta — the conversation tree patches

event: delta
data: {"p":"","o":"add","v":{"message":{"id":"…","author":{"role":"system"},"content":{...}}}}
  • p = JSON path (string, root "")
  • o = op (add, replace, remove, patch)
  • v = value (a full message object with id, author, content)

The stream replays the whole topic tree first: system → system → system → user → system … (the prior messages), then appends the new turn. Messages with create_time are persisted; ones with null are in-flight scaffolding.

Tool messages appear as:

{"author": {"role": "tool", "name": "web.run", "metadata": {"real_author": "tool:web.run"}}}

The web.run tool execution (web search) interleaves its result messages into the tree.

Infrastructure events (data-only)

resume_conversation_token

{"type":"resume_conversation_token","kind":"topic","token":"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.…"}

A JWT (ES256) issued at stream start — the resume token for the topic. Used by the resume flow (fjr) to continue an interrupted turn.

input_message

{"type":"input_message","input_message":{"id":"…","author":{"role":"user"},"create_time":1787769883.78}}

Echo of the user's message that triggered the turn (the server echoes the canonical record).

message_marker

{"type":"message_marker","conversation_id":"6a8f33f9-aa30-83e9-8d12-2116f4006fbd","message_id":"…","marker":"cot_token","event":"first"}

The pipeline stage markers, in order:

markermeaning
cot_tokenthe chain-of-thought token (the encrypted reasoning segment) is being emitted
user_visible_tokenthe user-visible text segment is being emitted
final_channel_tokenthe turn's final channel token (turn close)

Each marker carries event: "first" (observed; possibly last/delta_encoding for subsequent markers of the same message).

Stream metrics (observed)

messagechunksbytesevents
simple reply162104827
reply with web search333026740
second message242170232

What this closes

The static RE had the delta skeleton (channel/path/value, immer apply). The real stream shows:

  1. The tree is replayed then appended in one stream (no separate history fetch)
  2. Infrastructure events (resume token, input echo, message markers) ride the same SSE — no separate channel
  3. The encrypted reasoning integration: the cot_token marker precedes the user-visible text — the server tags which segment is the encrypted CoT
  4. Tool execution (web.run) interleaves result messages into the tree with role: tool

Cross-references

TypeScript types (wire + events)

// ── the wire delta keys (from the decoder YAr, asar) ─────────────────────
/** compressed keys: channel='c', path='p', op='o', value='v' */
export interface WireDelta {
  c?: number                    // channel — INHERITED from the previous delta when absent
  o: 'add' | 'replace' | 'remove' | 'patch' | 'append' | string
  p: string                     // JSON path ('' root, '/message/content/parts/0', …)
  v?: unknown                   // string for append fragments; message object for add/patch
}
/** The decoder state that provides the inheritance. */
export interface DeltaDecoderState {
  previousDelta: { channel: number; op: string; path: string; value: unknown }
  previousValueByChannel: unknown[]
}

// ── named SSE events ─────────────────────────────────────────────────────
export interface SseEvent<T extends string = string, D = unknown> {
  event: T
  data: D
}

/** delta_encoding: the first event of every stream. */
export type DeltaEncodingEvent = SseEvent<'delta_encoding', 'v1'>
export type DeltaEvent = SseEvent<'delta', WireDelta | WireDelta[]>

/** message_marker pipeline stages (observed 'first'; the last-marker events of a
 *  message may re-emit with 'last'/'delta_encoding' — see the page). */
export type MessageMarkerKind = 'cot_token' | 'user_visible_token' | 'final_channel_token'
export interface MessageMarkerEvent {
  type: 'message_marker'
  conversation_id: string
  message_id: string
  marker: MessageMarkerKind
  event: 'first' | 'last' | 'delta_encoding' | string
}

// ── data-only infrastructure events ──────────────────────────────────────
export interface ResumeConversationTokenEvent {
  type: 'resume_conversation_token'
  kind: 'topic'
  token: string                  // ES256 JWT — resume the interrupted turn
}
export interface InputMessageEvent {
  type: 'input_message'
  input_message: import('./flow-a-tool-protocol').ConversationMessage & { id: string }
}
export interface TitleGenerationEvent {
  type: 'title_generation'
  title: string
  conversation_id: string
}
export interface MessageStreamCompleteEvent {
  type: 'message_stream_complete'
  conversation_id: string
}
export interface ConversationDetailMetadataEvent {
  type: 'conversation_detail_metadata'
  banner_info: unknown | null
  blocked_features: unknown[]
  model_limits: unknown[]
  limits_progress: unknown[]
  [key: string]: unknown
}
export interface ServerSteMetadataEvent {
  type: 'server_ste_metadata'
  metadata: {
    server_ttfvt_ms: number | null
    conduit_prewarmed: boolean
    plan_type: string              // 'plus'
    plan_type_bucket: string       // 'paid'
    [key: string]: unknown
  }
}

Delta field details (from the full dump)

Field compression

Deltas carry fields as {c, o, p, v} — the c (channel) is inherited from the previous delta when absent. Observed: 2 of 6 deltas carried c; the rest inherited. This matches the ujr.previousDelta semantics from the static RE — now proven with real data (and confirmed directly in the asar decoder QAr with YAr = [['channel','c'],['path','p'],['op','o'],['value','v']]).

Ops observed

  • add — a whole message node into the tree root (p: "", channel 0)
  • append — streaming text: p: "/message/content/parts/0", v: "Oi, Alefita. Boa…" — fragments accumulate in parts[0] of the assistant message
  • patch — state updates at the root (p: "")

The assistant message metadata (real payload)

{
  "id": "<the message id — varies per message; the same id is the call_id for local tool calls when the recipient is local.<tool>>",
  "author": {"role": "assistant"},
  "content": {"content_type": "code", "language": "unknown", "text": "<tool result or intermediate text>"},
  "status": "finished_successfully", "end_turn": false,
  "recipient": "web.run", "channel": null,
  "metadata": {
    "finish_details": {"type": "stop", "stop_tokens": [200012]},
    "cot_version": "v5",
    "model_slug": "gpt-5-6-thinking",
    "default_model_slug": "gpt-5-6-thinking",
    "thinking_effort": "extended",
    "reasoning_title": "Searching the web",
    "reasoning_titles": ["Searching the web"],
    "reasoning_status": "is_reasoning",
    "reasoning_start_time": 1787770105.62,
    "parent_id": "c46ff5c8-277f-4e09-8215-93ce4bafc6b3",
    "request_id": "57af2415-69fa-47cb-a0b0-8b8c12745302",
    "tool_icons": ["globe"]
  },
  "conversation_id": "6a8f34f1-6b30-83e9-bf16-37e58ef7abbb"
}

Reasoning representation

reasoning appears in 12 events but no encrypted_content in the SSE — the chat submode carries reasoning as titles + markers (reasoning_title, cot_version: "v5", the cot_token message_marker). The encrypted CoT body is server-side, referenced by the marker token; it does not travel in the response stream. This differs from the codex backend, where the customer sends include: ["reasoning.encrypted_content"] and receives it in the payload.