OpenProgram Docs

Transcript wire protocol and modules

Part of the transcript model record. Built so far: implementation status.

Wire protocol

Negotiated per socket in websocket_dispatch.py. history_version: 3 sets _history_protocol = 3 and _bounded_history = True. The web sends 3 on list_sessions and load_session. The fragmentation gate in ws_delivery.py and the paging gate in load.py cover protocol 3. Version 3 replies are graph-free.

Requests. load_session keeps history_before, history_after, history_around, history_latest, now taking any row id, and adds history_turn for a one-turn read. history_snapshot and history_head are absent. search_session no longer takes a snapshot token. close_view { session_id, view } is new.

Replies. All fragment above 128 KiB.

FrameProtocol 3 shape
session_loadedmessages and history replaced by turns and window; every other field stays
session_history_page{ id, turns, window, request_id, action }
sub_agent_transcriptturns and window for its view key
chat_ackAdds first_read: { turns, window } when the socket holds no view of that session. Function and retry acks gain client_request_id, which chat acks already carry.

New frames.

transcript_update { session_id, view, previous, revision, changes: [...] }
  turn_upsert   { turn, afterTurnId }
  row_upsert    { turnId, afterRowId, row }
  item_upsert   { turnId, rowId, list: blocks | attachCards | runtimeChildren | callRoots, item, index? }
  row_patch     { turnId, rowId, fields }
  window_stale  { head_id, reason: branch | structure }
transcript_gap  { session_id }          critical; every held view of the session reads once
branches_changed { session_id }         replace class
view_closed     { session_id, view }    critical

index is required for list: blocks.

Changed frames, additive for all sockets. chat_response stream_event text and thinking gain row_id, item_id, item_index, offset. text_end gains row_id, item_id. Old clients still see seq.

The text event that opens a passage after a tool call, reasoning or a steer also carries separator: what the reply's flat text takes before the delta (A reply's text).

Every chat_response of a turn carries the reply's row_id, stamped by the turn's naming_reply_row wrap. The browser looks rows up by these ids and never builds one id from another.

ws_delivery.py.

  • New frame kind transcript, never replaced or evicted. On overflow, that session's queued transcript frames are removed and one critical transcript_gap enqueued; further transcript frames for that session are dropped until the gap leaves the queue. _evict_replaceable_for collapses a session's transcript frames into one gap instead of removing them.
  • _merge_adjacent merges stream text only when the same item_id is contiguous by offset.
  • Per-session parking of row-writing frames on QueuedWebSocket while a read is in flight.
  • The protocol 3 filter inside _enqueue, using the parse it already does.

Protocol 3 sockets do not receive stream_event tool_use and tool_result, tree_update or user_message; the publisher sends what they change as transcript updates.

They receive text, thinking, text_end, retry, structured_output_retry, terminal chat_response frames (run-level effects only, they write no row), chat_ack, running_task, running_task_clear, branch_running_task and its clear (a turn on a branch that is not selected), status, context_stats, goal_update, execution.updated. Slash /spawn and /merge result frames stay for other sockets; protocol 3 reducers cannot apply them to a row.

A retry frame with restart means the response is sent again from its start. The stream tap cuts the row's blocks back to where that response began and writes the row, so the next text frames carry offsets into the shortened row.

Tabs left open across a deploy need no new mechanism: frontend_build reloads them.

Modules

New

PathResponsibility
openprogram/interfaces/server/transcript/schema.pyTurn, Row, Block, TranscriptChange; source of generated TypeScript
.../transcript/turn_index.pyTranscriptView, membership, owner map, tip rule, compaction slots, derived-field table, LRU
.../transcript/turns.pyproject_turn(members, context), reusing aggregation, runtime card and truncation helpers on member rows
.../transcript/rows.pyproject_row and the rowKind decision
.../transcript/blocks.pyproject_block, block ids, truncation, fullOutput
.../transcript/children.pyattachCards, runtimeChildren, callRoots, blockId resolution
.../transcript/navigation.pySibling navigation through child maps, same rules as git/dag.py
.../transcript/status.pyThe status vocabulary and mapping from every stored form
.../transcript/legacy.pyEvery old record shape. An unknown shape draws as a plain row.
.../transcript/reader.pyfirst_read, page, one_turn, search; used by load.py, sub_agent.py, search.py and the chat acks
.../transcript/publisher.pyDrains observer records, resolves, projects, numbers, sends; holders, view cap, notice_tree, Stop rule
.../transcript/flat_rows.pyid, role, content lists for CLI, worker_turn, rehearsal, HTTP
apps/web/lib/chat/transcript/apply-transcript-update.tsThe only row writer: one pure reducer over the closed server changes and typed local changes (local append, replace, patch, remove, overlay set, overlay clear), returning effects
apps/web/lib/chat/transcript/apply-read.tsApplies a read to a view and settles the steers it delivered; adds local notices
apps/web/lib/net/ws/text-frames.tsBatches text frames per animation frame, places them by offset into every view holding the row, reports a lost frame
apps/web/lib/chat/transcript/owned-children.tsPairs blocks to children by id
apps/web/lib/chat/transcript/row-status.tsThe one isLive, isOpen, isSettled table
apps/web/lib/chat/transcript/wire-types.generated.tsGenerated by scripts/generators/generate_transcript_types.py
apps/web/components/chat/messages/list/transcript-rows.tsxThe one row list of the main chat, a split pane and the expanded sub-agent view: covering, goal records, decision receipts and rewind marks, with the session and view passed to every row
docs/reference/design/ui/transcript-model/overview.html + .zh.htmlEntry page of this engineering record; its topic pages sit beside it, all registered in PAGE_ORDER

Changed

PathChange
state/store/session/files/session_log.pyObserver at end of _append, gated by is_main_writer; quiet on patch_node
state/store/session/session_store/messages.py, storage.py, service.pyappend_message(advance_head=...), update_stream_progress, foreign-change notice at the stale rebuild and invalidate_cache
state/store/session/memory_index.pyrebuild swaps atomically
runtime/conversation/turn_runtime/stream_tap.pyPersist before emit; row_id, item_id, item_index, offset; naming_reply_row stamps row_id on every other frame of the turn
interfaces/server/server_runtime/session_persistence.py, ws_actions/session/load.py, ws_actions/chat/turn.py, runtime/jobs/runner/shared.pyreply_id on running_task and chat_ack; continues_job_id on job_status
runtime/conversation/turn_runtime/__init__.pyFinal blocks are tap.blocks when cancelled, otherwise _ordered_blocks or tap.blocks, at both call sites
runtime/conversation/turn_runtime/loop_runner.pyevent_parsing carries text_end block ids through the tap; steer metadata unchanged
runtime/conversation/peer_agents/sub_agent_run.py, programs/tools/agents/agent/agent/agent.pyrun_agent_turn(attach_pointer_id=...), sync placeholder from on_accepted, end write as patch
runtime/execution/projections/dag.pyReconcile closes attach rows whose job is not active
runtime/execution/event_effects.pyTerminal execution settles an open anchor row; paused and the return to running written; a chat turn stopped before it started gets its reply row, cancelled
runtime/context/git/dag.py_is_chat_lane rejects covers_ids. _is_side_row (function=attach, type=status with display=runtime, covers_ids) is skipped by deepest_leaf and the indexed latest_child, unless an ordinary row continues from it. active_branch_chain in branch order.
interfaces/server/persistence.pyaggregate_tool_messages copies lists (:166) and merges late calls on rows with no extra
interfaces/server/ws_delivery.pyWire protocol
interfaces/server/server_runtime/websocket_dispatch.pyVersion 3
interfaces/server/ws_actions/session/load.pyThin: resolve, read, send
interfaces/server/ws_actions/session/search.pyUses reader.search
interfaces/server/ws_actions/session/tool_output.pyAlso matches <message_id>_t_<node_id>
interfaces/server/ws_actions/sub_agent.pyServes the view through reader.py
interfaces/server/ws_actions/chat/turn.py, retry.py, turn_local_command.pyAck first_read. _build_user_msg stores client_request_id on the user row. retry.py reads it with client_request_id_of(cmd), and turn_local_command.py takes it from the _client_request_id context, each passing it to run_agent_method_call
interfaces/server/routes/chat.pyrun_agent_method_call(client_request_id=...) stores it in the pre-created node's metadata; POST /api/function/{name} accepts it in the body
interfaces/server/routes/control/commands.pyReads flat_rows
apps/web/lib/session-store/index.tsRows and turns per view behind selectRow(viewKey, id); windows hold turn ids and bytes only
apps/web/lib/net/ws/chat-stream.tsFrame routing, local send rows and run-level side effects; text batching moved to text-frames.ts; 1287 lines to 392
apps/web/lib/net/ws/session-load.tsaccept applies then sends pending; keyed by view
apps/web/lib/net/ws/use-ws.ts, lib/runtime-bridge/session/chat-handlers.ts, session-history-loader.ts, conversations.ts, lib/chat/history/history-window.tsWindows, close_view, no row writes
apps/web/components/chat/messages/list/use-history-window.ts, components/page-shell.tsx, navigation/conversation-find.tsxWindow-present tests instead of snapshot; no snapshot token
apps/web/components/chat/messages/list/rows/message-rows.tsx, bubbles/assistant-bubble.tsx, runtime/runtime-block.tsxDispatch on rowKind, children by blockId, stable keys, status from the row
apps/web/components/chat/messages/bubbles/user-bubble.tsxNotSent draws the row's errorDetail
apps/cli/src/screens/repl/useWsEvents.tsUnchanged

What is deleted

Everything in this table is gone from the repository. The last column names the step that removed it.

WhatWhereStep
conv_snapshot substitution on a failed readload.py:1621
Head flip and restore around attach and notice writessub_agent_run.py:577,665; slash_actions.py:195,324; inbox.py:225; conversation/peer_agents/merge.py:366; ws_actions/branch.py:528 (the mirror refresh at branch.py:562-565 stays)3
Hard-coded Running stepruntime-block.tsx:343-3524
FIFO and position pairing, keys txt_, fn_, seg_assistant-bubble.tsx4
Row minting and hand-kept shapes: replyId derivation, ensureReply, four-way tree_update, handleRuntimeRow, sub_agent case, finalize, handleSubAgentResponse row writes, handleUserMessage row writes, ensureSubAgentPromptchat-stream.ts, sub-agent-transcripts.ts8
Second terminal writer, running_task row targeting, settleClearedTurnRows, __reloadOnTaskClear, _pendingBranchReload and its setters, direct local_command and compaction appendschat-handlers.ts; use-function-dispatch.ts; runtime-block.tsx; message-editor.tsx:74; message-actions.tsx:264; rewind-actions.ts:88; state.ts:80,1658
Replay buffer: sequencedEvents, replayStreamAfterLoad, clearSessionByMsgId wiringchat-stream.ts, use-ws.ts8
Merge layers: retainChangedRows, reconcileMessageSnapshot, hasMissingProgress, preserveSessionReadRows, loader merge at session-history-loader.ts:189-197session-load.ts, message-snapshot.ts, runtime-bridge/session/session-load.ts8
settledExecution overlayassistant-bubble.tsx:254-2618
applyChapterFrame row writechapter-pin.ts, use-ws.ts:944-947 (the frame stays as the request's reply)8
rememberSystemAccessFromTree, liveRequests, hasSystemAccessRequest, consumeSystemAccessRequest (no production reader) and their testssystem-access-result.ts, chat-stream.ts:584,8418
Job-status re-read of the expanded viewsub-agent-transcript.tsx:978
Public store writers appendMessage, updateMessage, removeMessage, rekeyMessage, truncateFrom, setMessages (72 calls in 17 files); the read-only messagesById index (132 references in 32 files)session-store/index.ts8
Content, display and function sniffing in dispatch, GOAL_SPAWN_LABELS, client receipt classification, coversIds coveringmessage-rows.tsx, agent-notices.ts, message-list.tsx9
Window-dependent folds and web use of convToChatMsgs; the fileconv-mapper.ts10
markRestartContinuations, store-wide restartPredecessors. joinedReply remains.restart-continuation.ts10
Old-order pairing fallbackowned-children.ts10
conv.messages as a transcript copy, feedStoreFromConv, spliceCompactionFromGraph, wire-row chunksconversations.ts, history-window.ts10
HistorySnapshot, per-connection temp files, snapshot token, patch_message, install_snapshot, close_snapshots, history_page, snapshot loop in chapter.py:40-58session_history.py (file removed); QueuedWebSocket.stop call10
_splice_attach_pointers, _splice_runtime_placeholders, _rows_with_sibling_navigation, _page_history_window, _serve_cached_history_page, writing the spliced chain into conv['messages'] (the mirror stays for its other readers, filled from get_branch)load.py10
All 23 session_reload emission sites, the three self-update ones included, and the web caseevent_effects.py (4); submission.py; recovery.py (3); cancellation.py (2); shared.py; progress.py (2); sub_agent_run.py; slash_actions.py (2); always_on/runtime.py; self_update/delivery/delivery.py, owner_notice.py, control/held_turns.py; ws_actions/merge.py, branch.py, dag_nodes.py; re-export in jobs/runner/__init__.py; use-ws.ts; chat-handlers.ts10
emit_spawn_event and the sub_agent stream eventsub_agent_run.py:440-485, agent.py call sites10
_poll_progress and its job_progress reason (no caller)jobs/runner/progress.py:127-21010
Protocol 1 and 2 web pathsload.py, session_history.py, web client10
PUBLISH_CHAT_ROWS and its False side: terminal-frame parking, the reload kept for a socket with no view; the rows_published stamptranscript/publisher.py, ws_delivery.py10
The compare tool and the live mapper side of golden parity; the mapper's rows are frozen in mapper-rows.jsoncompare_transcript_projection.py, the parity test10
Client id derivation: replyRowId, executionKey, the decision anchor and pending-steer _reply suffixes, the _user_reply parse of a Job's parentchat-stream.ts, chat-handlers.ts, running-task-clear.ts, session-store/index.ts, pending-steers.tsx, sub-agent-transcripts.ts10

Delivery steps

Last updated · 2026-11-25