Loading AgentsKit ecosystem navigation…
AgentsKit Chat

Streaming lifecycle

Cancel, retry, edit, regenerate — AgentsKit owns semantics; Chat shells expose them.

View canonical Markdown

Streaming lifecycle

AgentsKit owns the lifecycle. AgentsKit Chat renderers expose the same ChatReturn operations without reimplementing abort or stream reducers.

Operations

OperationAgentsKit methodDefault shell
Cancelstop()Stop button · Escape in Ink
Retryretry()Retry · /retry in Ink
Editedit(messageId, content)Edit last message · /edit … in Ink
Regenerateregenerate(messageId?)Regenerate · /regenerate in Ink

Visual map

Loading diagram...

Cancellation aborts the upstream source. AgentsKit prevents late chunks from mutating canonical state after abort.

Lineage and reconnect

A v1 server.turn.snapshot may include lineage:

code
{
  "lineage": {
    "operation": "regenerate",
    "parentTurnId": "turn-previous",
    "sourceMessageId": "message-assistant"
  }
}
  • createSnapshotEvent(...) projects canonical messages + submit/retry/edit/regenerate lineage.
  • createTurnSnapshotCursor(sessionId) applies snapshots from a transport.
  • First valid snapshot initializes reconnect; later snapshots need a greater sequence.
  • Duplicate, stale, malformed, and foreign-session events are no-ops.

Snapshots are complete projections. The cursor chooses the current projection — it never merges messages or interprets adapter chunks.

In the docs assistant

The floating Ask the docs shell shows Retry / Regenerate / Edit after a completed turn — same operations as production shells.