Claude chat: a history read mid-reply carries the streaming block's beginning
Claude Code writes a content block to its session file only once the block is complete. A client that read history while a block streamed (opening the chat mid-reply, a reconnect, a resync) got only the deltas after its read, and nothing re-sent the block's beginning, so the reply showed with its first part cut off. Deltas are now numbered (seq) and their text retained for the newest assistant messages; the newest history page adds every retained part the transcript lacks and reports the last included seq (live_seq) and the overlaid parts (live_parts). History now numbers empty text/thinking blocks as the live stream does, so a thinking block after an empty display-omitted one keeps one part id live and in history. Text a content_block_start carries is published, not dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -528,6 +528,16 @@ type ChatHistoryPage struct {
|
||||
Messages []ChatMessage `json:"messages"`
|
||||
NextCursor string `json:"next_cursor,omitempty"`
|
||||
HasMore bool `json:"has_more,omitempty"`
|
||||
// LiveSeq is the Seq of the last streamed text or reasoning delta the
|
||||
// newest page includes. A harness whose stored transcript lacks the content
|
||||
// block still streaming (Claude Code writes a block only once it is
|
||||
// complete) adds that block's text so far to the newest page, under its
|
||||
// live part id, and names it in LiveParts. A client folds a delta frame
|
||||
// with a greater Seq onto a live part or onto a part the page lacks; every
|
||||
// delta with Seq <= LiveSeq is already in the page. Zero when the harness
|
||||
// does not number its deltas.
|
||||
LiveSeq int64 `json:"live_seq,omitempty"`
|
||||
LiveParts []string `json:"live_parts,omitempty"`
|
||||
}
|
||||
|
||||
// ChatPromptRequest is the chat_prompt request body: the text to send, with an
|
||||
@@ -745,6 +755,9 @@ type ChatEventFrame struct {
|
||||
// MessageKind is the ChatMessage.Kind of the message a text frame starts,
|
||||
// so a live agent report or notice is never drawn as an answer or a prompt.
|
||||
MessageKind string `json:"message_kind,omitempty"`
|
||||
// Seq numbers a text or reasoning delta within its session, increasing;
|
||||
// see ChatHistoryPage.LiveSeq. Zero when the harness does not number them.
|
||||
Seq int64 `json:"seq,omitempty"`
|
||||
}
|
||||
|
||||
// ChatCompaction is session activity, never a transcript message or tool.
|
||||
|
||||
Reference in New Issue
Block a user