Repository navigation
chat: deferred turns, Turn union, and legacy tail-window paging - #620
Open
Osvaldo Ortega (osortega) wants to merge 6 commits into
Open
Osvaldo Ortega (osortega) wants to merge 6 commits into
Osvaldo Ortega (osortega) wants to merge 6 commits into
Conversation
Let clients list prompt previews, read a contiguous window by turn ID, and locate matching text without extending the live subscription. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 20, 2026
Make the prompt index and direct turn-window reads available on their own. Advertise the pair with a per-chat presence object; keep subscription paging unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Start at the selected turn rather than centering a window. Return opaque continuations on each available side, leaving the live chat subscription unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rework the history-navigation proposal into deferred turns, per discussion
with Osvaldo:
- ChatState.turns is now ChatStateTurn[] (Turn | DeferredTurn), discriminated
by isDeferred. A DeferredTurn keeps id, message, state, usage and timing
but omits responseParts.
- Clients opt in with ClientCapabilities.deferredTurns; hosts must not send
deferred turns to clients that don't declare it.
- New chat-channel command fetchDeferredTurns { turnId, endTurnId? } asks the
host to dispatch chat/turnsMaterialized, which replaces deferred turns in
place with full turns.
- chat/turnsLoaded may carry deferred turns; chat/turnResume is a no-op on a
deferred turn.
- Remove listChatTurns/readChatTurns, historyBrowsing, and @wireFields
generator support.
- Native clients model ChatStateTurn as a two-variant union with hand-written
reducer support; JSON Schema now emits const for boolean literal types.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Rename the full completed-turn type Turn -> MaterializedTurn, and make Turn the MaterializedTurn | DeferredTurn union used by ChatState.turns and chat/turnsLoaded (formerly ChatStateTurn). This is a breaking change for SDK source; the wire format is unchanged. - Mark tail-window paging (SubscribeView.turns, ChatState.turnsNextCursor, fetchTurns, chat/turnsLoaded) @deprecated and Legacy (stability 3) in favour of deferred turns. It stays supported for 1.x clients that don't declare deferredTurns; hosts SHOULD NOT window deferred-capable clients. - Update all native generators, reducers, docs, and change fragments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Connor Peet (connor4312)
marked this pull request as ready for review
November 24, 2026 22:58
Connor Peet (connor4312)
requested review from
Connor Peet (connor4312) and
roblourens
as code owners
November 24, 2026 22:58
Regenerate clients after the merge and renumber the deferred-turn round-trip fixtures to 103-104 to avoid colliding with main's 100-102. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Connor Peet (connor4312)
enabled auto-merge
November 24, 2026 23:45
roblourens
approved these changes
Nov 25, 2026
This branch has not been deployed
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.
Lets a client show a long chat's full prompt list without downloading every response, and expand turns on demand. This builds on the design discussed with Osvaldo Ortega (@osortega).
Protocol
ClientCapabilities.deferredTurns. Hosts MUST NOT send deferred turns to clients that didn't declare it, so existing clients keep receiving full turns.ChatState.turnsmay be aDeferredTurn. It keeps the turn'sid,message,state,usageand timing, setsisDeferred: true, and omitsresponseParts. Deferred turns stay in place inturns, so actions that refer to turns by ID keep working.fetchDeferredTurns { channel, turnId, endTurnId? }asks the host to dispatchchat/turnsMaterialized, which replaces the deferred turns in that inclusive range with full turns, in place.chat/turnResumedoes nothing on a deferred turn. The host must materialize it first.Breaking SDK change (wire format unchanged):
Turnis now the unionMaterializedTurn | DeferredTurn, and the old fullTurnis renamedMaterializedTurn. Code that readsresponsePartsmust narrow to the materialized variant first. Each native client modelsTurnas a two-variant union, decodingisDeferred: trueas deferred and anything else as materialized.Deprecation: tail-window paging (
view.turns,ChatState.turnsNextCursor,fetchTurns,chat/turnsLoaded) is now@deprecatedwith stability Legacy (3). It still works for 1.x clients that don't declaredeferredTurns. Hosts SHOULD send deferred-capable clients every retained turn, deferring any they choose, rather than a tail window.This replaces the earlier
listChatTurns/readChatTurnsdesign in this PR. #623 was stacked on that design and will need rework.Spec: Deferred turns
Other changes
{ type: boolean, const }for boolean literal types, sooneOfcan tellMaterializedTurnfromDeferredTurn. This also tightens the existingapprovedliteral ontoolCallConfirmed.330–332and round-trip100–101.Validation:
npm run generateandnpm testpass (677). The client suites pass in TypeScript, Go, Rust (with fmt and clippy), Swift, Kotlin (JDK 17 in podman) and .NET (offline restore on the local SDK, because podman couldn't reach nuget.org).