Repository navigation
Read a session as a conversation: GET /sessions/{id}/transcript - #251
Merged
Merged
Conversation
GET /sessions/{id}/transcript turns a session's stored request and
response bodies into the conversation the desktop app shows: per turn,
the messages new in that request, the answer decoded from the stored
response, and what could not be shown (gaps). Control-plane protocol 32.
Clients resend the whole history every turn, so a request's new messages
are what is left after the previous readable request's messages,
compared by fingerprint with cache_control, signatures, key order and
reasoning ignored (some clients drop earlier reasoning from the
history). The first leftover assistant message is the previous turn's
answer and is dropped, unless that answer could not be read in full.
No prefix match, or an unreadable request before it, restarts with the
whole history.
Requests are read from the client's own JSON instead of tw-dialect's IR:
the IR drops exactly what a transcript needs (where a system message
sits, tool-only messages, server-tool blocks, files). Answers reuse
tw-dialect's per-format stream parsers, and the blocks those skip are
recognized on the same frame. Every string is masked with mask_body on
the way out; images carry only their type and size.
300 turns at about 1.2 MB a request build in about 0.7 s (release).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 2, 2026
Merged
fylorn
added a commit
that referenced
this pull request
Oct 3, 2026
Release for #251, #252, #263, #265, #268 and #272, with the pre-release fixes in #273. - Bump the workspace version to 0.58.0 - release-notes/0.58.0.md The control-plane protocol (34) and the request store schema (25) are already at their release values on main and do not change here. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
New control-plane endpoint
GET /sessions/{id}/transcript(Transcript). It reads a session's stored request and response bodies into a conversation: for every turn, the messages that are new in that request, the answer decoded from the stored response, and what could not be shown. Control-plane protocol 32.Why
The session view shows each turn's tokens and cost (
SessionDetail) but not what was said. The bodies are on disk, but clients resend the whole history on every turn, so showing them raw repeats everything hundreds of times.How a turn is read
Db::session_requestsuses the same filter and order asDb::turns.idis the request id as a decimal string.search::text::client_dialect), the upstream format from the row'stranslated.to, otherwise the client's. Calls that do not generate an answer (count_tokens,/responses/compact) are empty turns and are not compared with their neighbours.output). Messages are compared by a 16-byte fingerprint of a normalized form:cache_control, reasoning signatures and key order are ignored, and so is reasoning text, because some clients drop earlier reasoning from the history. No prefix, or an unreadable request in between, givesrestart: trueand the whole history.response_*gap). It is then the only record of what was said.tool(Anthropictool_result-only user messages, Chattool, Responses*_call_output). Consecutive assistant items (a Responses answer is several items) and consecutive tool results merge into one message; user messages do not. Mid-conversation system and developer messages aresystem. Leading ones in Chat and Responses are part of the system prompt, afterinstructions.otherwith their type name (document,server_tool_use,web_search_call,compaction,input_audio…). Images give only the media type and the decoded size.bedrock::decode_response.{"input": …}are unwrapped, as the gateway does.request_missing;request_truncated(a.lensidecar longer than the stored body, or JSON that does not parse);response_missing(2xx with bytes received but no body file);response_truncated(decoded as far as it goes);response_unreadable(a body that is not this upstream's answer). A failed request (non-2xx) has no output and no gap, since the failure is already inTurnView. A request cancelled before its first byte has neither.tw_secret::mask_bodyafter decoding, at the end. That is stricter than masking the raw JSON: a key right after a\nescape is masked too. Image data and reasoning signatures never leave.control.session_not_found, the same code/sessions/{id}uses. No new message codes.spawn_blocking, as in content search.How it was verified
cargo fmt --all -- --check: cleancargo clippy --workspace --all-targets -- -D warnings: cleanenv -u HTTP_PROXY -u HTTPS_PROXY -u http_proxy -u https_proxy cargo test --workspace --no-fail-fast: 2064 passed, 0 failed, 6 ignored (1 new: the cost test below)cargo clippy -p tw-api --all-targets --features ts -- -D warnings,cargo test -p tw-api --features ts(a new test pins the exported declarations),export_ts, thentsc --noEmit --strict --target es2022: cleanscripts/smoke.sh: 69 passed, 0 failed, plus the existing memory warning. The new check reads every session the run creates on the real binary: 3 sessions, 6 turns. Turn ids match/sessions/{id}, no secret appears, and the Bedrock eventstream answer comes back asbedrock-streamtext.tw-store(17) andtw-control(3):tool_use/tool_result, a screenshot inside a tool result); OpenAI Chat withtool_calls/tooland a mid-conversation system message, streamed and whole; Codex on Responses (instructionsplus developer message, reasoning items,function_call/function_call_output,custom_tool_callapply_patch, a hostedweb_search_call); GeminifunctionCall/functionResponsewithout idscount_tokenscall in the middle; a failed turn and its retrycargo test --release -p tw-store transcript_cost -- --ignored --nocapture): a 300-turn Claude Code-like session, 367 MB of bodies (1.2 MB a request on average), builds in 0.69–0.74 s, about 2.3 ms a request. The JSON is 1.5 MB. Each body is parsed once and dropped after its turn; only per-message fingerprints and the system prompt carry over.Notes for review
TranscriptTurn.idis a string, as the desktop app asked, whileTurnView.idis a number.request_truncated, because its new messages are at the end that was cut. Answers over the current 256 KiB response cap areresponse_truncatedand show what fits.🤖 Generated with Claude Code