Chat and runs: tell a slow client to resync instead of dropping it silently; join queued deltas

A chat subscriber whose queue fills is detached and its writer ends the
stream with a resync frame (the app re-attaches and re-reads history); a run
subscriber gets a final runs_resync and the app subscribes again and
re-reads the Runs list and open detail. Consecutive text/reasoning deltas of
one part are joined in a chat subscriber's queue; joined numbered frames carry
seq_from and delta_lens so the app trims exactly the prefix a history page
already holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:39:38 +00:00
parent e649eced10
commit c316bc9bc8
20 changed files with 603 additions and 80 deletions
+10
View File
@@ -480,6 +480,16 @@ history refresh without inventing text deltas or ending a queued prompt. Native
step markers may include `step.turn_id`; a terminal marker for an older turn
must not clear a newer turn's Stop control or release its queue slot.
A client that falls too far behind its chat stream (64 queued frames) is
detached; its last frame is `chat_event.kind="resync"`, so it must send
`chat_subscribe` again before re-reading history. Consecutive text or reasoning
deltas of one part are joined while queued: a joined numbered frame carries
`seq` (its last delta), `seq_from` (its first) and `delta_lens` (each delta's
length in UTF-16 code units), so a client whose history page's `liveSeq`
falls inside the range drops exactly the prefix the page already holds. A run
subscriber that falls behind likewise receives a final `{"type":"runs_resync"}`
and must send `subscribe` again for a fresh snapshot.
Native context compaction is reported as `chat_event.kind="compaction"`, with
`compaction: {status: "running" | "completed" | "failed", id?: string}`.
Optional `native_turn_id` scopes the activity to its real harness turn; ignore