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.
| Frame | Protocol 3 shape |
|---|---|
session_loaded | messages and history replaced by turns and window; every other field stays |
session_history_page | { id, turns, window, request_id, action } |
sub_agent_transcript | turns and window for its view key |
chat_ack | Adds 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 criticaltranscript_gapenqueued; further transcript frames for that session are dropped until the gap leaves the queue._evict_replaceable_forcollapses a session's transcript frames into one gap instead of removing them. _merge_adjacentmerges stream text only when the sameitem_idis contiguous byoffset.- Per-session parking of row-writing frames on
QueuedWebSocketwhile 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
| Path | Responsibility |
|---|---|
openprogram/interfaces/server/transcript/schema.py | Turn, Row, Block, TranscriptChange; source of generated TypeScript |
.../transcript/turn_index.py | TranscriptView, membership, owner map, tip rule, compaction slots, derived-field table, LRU |
.../transcript/turns.py | project_turn(members, context), reusing aggregation, runtime card and truncation helpers on member rows |
.../transcript/rows.py | project_row and the rowKind decision |
.../transcript/blocks.py | project_block, block ids, truncation, fullOutput |
.../transcript/children.py | attachCards, runtimeChildren, callRoots, blockId resolution |
.../transcript/navigation.py | Sibling navigation through child maps, same rules as git/dag.py |
.../transcript/status.py | The status vocabulary and mapping from every stored form |
.../transcript/legacy.py | Every old record shape. An unknown shape draws as a plain row. |
.../transcript/reader.py | first_read, page, one_turn, search; used by load.py, sub_agent.py, search.py and the chat acks |
.../transcript/publisher.py | Drains observer records, resolves, projects, numbers, sends; holders, view cap, notice_tree, Stop rule |
.../transcript/flat_rows.py | id, role, content lists for CLI, worker_turn, rehearsal, HTTP |
apps/web/lib/chat/transcript/apply-transcript-update.ts | The 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.ts | Applies a read to a view and settles the steers it delivered; adds local notices |
apps/web/lib/net/ws/text-frames.ts | Batches 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.ts | Pairs blocks to children by id |
apps/web/lib/chat/transcript/row-status.ts | The one isLive, isOpen, isSettled table |
apps/web/lib/chat/transcript/wire-types.generated.ts | Generated by scripts/generators/generate_transcript_types.py |
apps/web/components/chat/messages/list/transcript-rows.tsx | The 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.html | Entry page of this engineering record; its topic pages sit beside it, all registered in PAGE_ORDER |
Changed
| Path | Change |
|---|---|
state/store/session/files/session_log.py | Observer at end of _append, gated by is_main_writer; quiet on patch_node |
state/store/session/session_store/messages.py, storage.py, service.py | append_message(advance_head=...), update_stream_progress, foreign-change notice at the stale rebuild and invalidate_cache |
state/store/session/memory_index.py | rebuild swaps atomically |
runtime/conversation/turn_runtime/stream_tap.py | Persist 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.py | reply_id on running_task and chat_ack; continues_job_id on job_status |
runtime/conversation/turn_runtime/__init__.py | Final blocks are tap.blocks when cancelled, otherwise _ordered_blocks or tap.blocks, at both call sites |
runtime/conversation/turn_runtime/loop_runner.py | event_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.py | run_agent_turn(attach_pointer_id=...), sync placeholder from on_accepted, end write as patch |
runtime/execution/projections/dag.py | Reconcile closes attach rows whose job is not active |
runtime/execution/event_effects.py | Terminal 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.py | aggregate_tool_messages copies lists (:166) and merges late calls on rows with no extra |
interfaces/server/ws_delivery.py | Wire protocol |
interfaces/server/server_runtime/websocket_dispatch.py | Version 3 |
interfaces/server/ws_actions/session/load.py | Thin: resolve, read, send |
interfaces/server/ws_actions/session/search.py | Uses reader.search |
interfaces/server/ws_actions/session/tool_output.py | Also matches <message_id>_t_<node_id> |
interfaces/server/ws_actions/sub_agent.py | Serves the view through reader.py |
interfaces/server/ws_actions/chat/turn.py, retry.py, turn_local_command.py | Ack 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.py | run_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.py | Reads flat_rows |
apps/web/lib/session-store/index.ts | Rows and turns per view behind selectRow(viewKey, id); windows hold turn ids and bytes only |
apps/web/lib/net/ws/chat-stream.ts | Frame 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.ts | accept 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.ts | Windows, close_view, no row writes |
apps/web/components/chat/messages/list/use-history-window.ts, components/page-shell.tsx, navigation/conversation-find.tsx | Window-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.tsx | Dispatch on rowKind, children by blockId, stable keys, status from the row |
apps/web/components/chat/messages/bubbles/user-bubble.tsx | NotSent draws the row's errorDetail |
apps/cli/src/screens/repl/useWsEvents.ts | Unchanged |
What is deleted
Everything in this table is gone from the repository. The last column names the step that removed it.
| What | Where | Step |
|---|---|---|
conv_snapshot substitution on a failed read | load.py:162 | 1 |
| Head flip and restore around attach and notice writes | sub_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 step | runtime-block.tsx:343-352 | 4 |
FIFO and position pairing, keys txt_, fn_, seg_ | assistant-bubble.tsx | 4 |
Row minting and hand-kept shapes: replyId derivation, ensureReply, four-way tree_update, handleRuntimeRow, sub_agent case, finalize, handleSubAgentResponse row writes, handleUserMessage row writes, ensureSubAgentPrompt | chat-stream.ts, sub-agent-transcripts.ts | 8 |
Second terminal writer, running_task row targeting, settleClearedTurnRows, __reloadOnTaskClear, _pendingBranchReload and its setters, direct local_command and compaction appends | chat-handlers.ts; use-function-dispatch.ts; runtime-block.tsx; message-editor.tsx:74; message-actions.tsx:264; rewind-actions.ts:88; state.ts:80,165 | 8 |
Replay buffer: sequencedEvents, replayStreamAfterLoad, clearSessionByMsgId wiring | chat-stream.ts, use-ws.ts | 8 |
Merge layers: retainChangedRows, reconcileMessageSnapshot, hasMissingProgress, preserveSessionReadRows, loader merge at session-history-loader.ts:189-197 | session-load.ts, message-snapshot.ts, runtime-bridge/session/session-load.ts | 8 |
settledExecution overlay | assistant-bubble.tsx:254-261 | 8 |
applyChapterFrame row write | chapter-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 tests | system-access-result.ts, chat-stream.ts:584,841 | 8 |
| Job-status re-read of the expanded view | sub-agent-transcript.tsx:97 | 8 |
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.ts | 8 |
Content, display and function sniffing in dispatch, GOAL_SPAWN_LABELS, client receipt classification, coversIds covering | message-rows.tsx, agent-notices.ts, message-list.tsx | 9 |
Window-dependent folds and web use of convToChatMsgs; the file | conv-mapper.ts | 10 |
markRestartContinuations, store-wide restartPredecessors. joinedReply remains. | restart-continuation.ts | 10 |
| Old-order pairing fallback | owned-children.ts | 10 |
conv.messages as a transcript copy, feedStoreFromConv, spliceCompactionFromGraph, wire-row chunks | conversations.ts, history-window.ts | 10 |
HistorySnapshot, per-connection temp files, snapshot token, patch_message, install_snapshot, close_snapshots, history_page, snapshot loop in chapter.py:40-58 | session_history.py (file removed); QueuedWebSocket.stop call | 10 |
_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.py | 10 |
All 23 session_reload emission sites, the three self-update ones included, and the web case | event_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.ts | 10 |
emit_spawn_event and the sub_agent stream event | sub_agent_run.py:440-485, agent.py call sites | 10 |
_poll_progress and its job_progress reason (no caller) | jobs/runner/progress.py:127-210 | 10 |
| Protocol 1 and 2 web paths | load.py, session_history.py, web client | 10 |
PUBLISH_CHAT_ROWS and its False side: terminal-frame parking, the reload kept for a socket with no view; the rows_published stamp | transcript/publisher.py, ws_delivery.py | 10 |
The compare tool and the live mapper side of golden parity; the mapper's rows are frozen in mapper-rows.json | compare_transcript_projection.py, the parity test | 10 |
Client id derivation: replyRowId, executionKey, the decision anchor and pending-steer _reply suffixes, the _user_reply parse of a Job's parent | chat-stream.ts, chat-handlers.ts, running-task-clear.ts, session-store/index.ts, pending-steers.tsx, sub-agent-transcripts.ts | 10 |