| title |
|---|
Turn-complete signal for session/update |
Author(s): @stablegenius49
What are you proposing to change?
Add a protocol-level turn_complete signal so clients can reliably know when a prompt turn's session/update stream is finished, without using arbitrary sleeps.
How do things work today and what problems does this cause? Why would we change things?
Today, clients call session/prompt and receive:
- zero or more
session/updatenotifications (chunks, tool call updates, usage, etc.) - a
session/promptresponse withstopReason
In practice, some client implementations process notifications asynchronously. This means session/prompt can resolve before all queued session/update handlers complete locally. Clients then fall back to timing heuristics (sleep(100ms)), which are racy and add latency.
For advanced UIs (multi-pane streaming, usage counters, transcript persistence, tool timeline integrity), this is a correctness issue, not just UX polish.
What are you proposing to improve the situation?
Introduce a new session/update variant:
sessionUpdate: "turn_complete"
Semantics:
- Emitted once per prompt turn.
- Emitted after all other updates for that turn have been sent.
- Includes a turn correlation field so clients can match it to the originating prompt request.
Proposed shape (illustrative):
{
"jsonrpc": "2.0",
"method": "session/update",
"params": {
"sessionId": "sess_abc123def456",
"update": {
"sessionUpdate": "turn_complete",
"promptRequestId": "2",
"stopReason": "end_turn"
}
}
}To make this reliable for clients, support should be explicit via session capabilities:
{
"agentCapabilities": {
"sessionCapabilities": {
"turnComplete": {}
}
}
}Clients can then use strict synchronization when supported, and fallback behavior otherwise.
How will things will play out once this feature exists?
- Clients stop using sleep-based hacks.
- Prompt turn boundaries become explicit and auditable in event logs.
- SDKs can provide a clean “await until turn stream drained” primitive.
- Multi-client/proxy setups get deterministic end-of-turn ordering, which composes better with ongoing session-list/session-info/session-usage work.
Tell me more about your implementation. What is your detailed implementation plan?
- Add unstable
TurnCompleteUpdateschema/type. - Add
turnCompletemarker undersessionCapabilities. - Document ordering requirement:
- For a given prompt turn, all non-
turn_completeupdates must be emitted beforeturn_complete.
- For a given prompt turn, all non-
- Add ergonomic helpers in SDKs (Rust/Python/TS) to await turn completion by
promptRequestId. - Add conformance tests validating event ordering and single-emission behavior.
- Gather feedback from clients currently using sleep-based workarounds.
- Stabilize once at least two independent client implementations adopt it.
What questions have arisen over the course of authoring this document or during subsequent discussions?
Because response completion and notification-handler completion can diverge in async client runtimes. We need an explicit stream barrier in the same update channel clients already consume.
Keeping it inside session/update avoids adding another channel and preserves existing per-session ordering machinery.
To support robust correlation in clients with concurrent internal pipelines and to make replay/log analysis unambiguous.
- 2026-03-04: Initial draft for issue #554