You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI Transport docs: drain run.view before run.start()
run.start() awaits run.located, and on a cold start the triggering input
only folds into the tree once the caller pages run.view — so draining after
start() can hang. Reorder every agent example to drain (loadOlder loop) and
build the conversation before calling run.start(), matching the SDK's own
v0.4.0 docs (streaming.md, database-hydration.md) and the AgentRun.start
contract. Affects agent-session, run-outcome, the agent-route feature pages,
both frameworks pages, and both getting-started guides. database-hydration
already used the correct loadUntil-then-start order.
Also: chain-of-thought used "turn" for the Run lifecycle unit (abort signal,
stream multiplexing, post-completion) inconsistently with the rest of the
page — align to "Run". Fix "client-side React hooks" casing on the Vercel
AI SDK UI page.
AIT-1090
Subscribe to the channel and implicitly attach. The subscribe is unfiltered so channel-history-replayed input events fold into the tree, where each run's input-event watcher can match its trigger. Idempotent: subsequent calls return the same promise. All `AgentRun` methods (`start`, `pipe`, `suspend`, `end`) throw `InvalidArgument` until `connect()` has been called.
94
+
Attaches and subscribes to the channel backing the session. Idempotent: subsequent calls return the same promise. All `AgentRun` methods (`start`, `pipe`, `suspend`, `end`) throw `InvalidArgument` until `connect()` has been called.
Create a new `AgentRun`from an `Invocation`. Returns synchronously and arms the run's input-event watcher (a passive pre-scan of the tree plus a listener for the trigger's arrival); it publishes nothing to the channel until [`AgentRun.start`](#run-start) is called. The run is registered for cancel routing immediately so early cancels fire the `abortSignal`.
110
+
Create a new `AgentRun`for the inputevent named in the `Invocation`. Returns synchronously and publishes nothing to the channel until [`AgentRun.start`](#run-start) is called. The run is registered for cancel routing immediately so early cancels fire the `abortSignal`.
111
111
112
112
<Code>
113
113
```javascript
@@ -167,21 +167,21 @@ The handle returned by [`createRun`](#create-run). It extends the shared `BaseRu
167
167
| runId | The Run's unique identifier. Known synchronously on the agent (it mints the id for a fresh run, or reads it off the triggering input event for a continuation). | String |
168
168
| status | The Run's lifecycle status, read live off the tree. |`RunStatus`|
169
169
| error | The terminal error, present exactly when `status` is `'error'`. |`Ably.ErrorInfo` or Undefined |
170
-
| messages |This Run's whole turn: its triggering input message followed by its own streamed output, deduplicated by `codecMessageId`. The unit to persist. See [Hydrate the conversation](#conversation-hydration). |`TMessage[]`|
170
+
| messages |All of this Run's messages: its triggering input followed by its streamed output (across any suspend and resume), deduplicated by `codecMessageId`. The unit to persist. See [Hydrate the conversation](#conversation-hydration). |`TMessage[]`|
171
171
| invocationId | The invocation id minted by the agent for this `createRun` call (one per HTTP request). Readable synchronously; the application returns it on the HTTP response. The agent stamps it on every event it publishes for this invocation. | String |
172
172
| abortSignal |`AbortSignal` scoped to this Run. Fires when a cancel event arrives. |`AbortSignal`|
173
-
| view |Read-only, leaf-pinned `View<TMessage>` of this Run's branch, from its triggering input back to the conversation root. Drain it with `loadOlder()` for ancestor context to feed the model. Empty until the trigger folds into the tree. See [Hydrate the conversation](#conversation-hydration). |`View<TMessage>`|
174
-
| located | Resolves when this Run's triggering input folds into the tree (live or via a `view.loadOlder()` page). [`start`](#run-start) awaits it internally; await it directly only to read the trigger before deciding how to start. |`Promise<void>`|
173
+
| view |A read-only`View<TMessage>` of the conversation branch this Run belongs to, from its triggering input back to the conversation root. Use it to reconstruct the conversation to feed the model. See [Hydrate the conversation](#conversation-hydration). |`View<TMessage>`|
174
+
| located | Resolves once the Run's triggering input (named in its invocation) has been observed on the channel, whether through the live subscription or by paging history with `view.loadOlder()`. [`start`](#run-start) awaits it internally; await it directly only to read the trigger before deciding how to start. |`Promise<void>`|
Await [`located`](#run) (the run's input-event watcher resolves the trigger, whether it arrives live or already sits in channel history), then read the trigger's wire headers and publish the opening lifecycle event (`ai-run-start`, or `ai-run-resume` for a continuation). Must be called before `pipe`, `suspend`, or `end`.
182
+
Wait until the Run's triggering input has been observed on the channel (see [`located`](#run)), then publish the opening lifecycle event (`ai-run-start`, or `ai-run-resume` for a continuation). Must be called before `pipe`, `suspend`, or `end`.
183
183
184
-
There is no built-in deadline: `start()` does not time out waiting for the trigger. It rejects only if the run is cancelled or the session is closed before the trigger folds in. Race it against your own timeout if you need one.
184
+
There is no built-in deadline: `start()` does not time out waiting for the trigger. It rejects only if the run is cancelled or the session is closed before the trigger is observed. Race it against your own timeout if you need one.
Two accessors expose conversation content, at different scopes:
335
335
336
-
-`run.messages` is this Run's own turn: its triggering input plus its streamed output. This is the unit to persist, not the value to feed the model in a multi-turn conversation.
336
+
-`run.messages` is all of this Run's own messages: its triggering input plus its streamed output (across any suspend and resume). This is the unit to persist, not the value to feed the model in a multi-turn conversation.
337
337
-`run.view` is a read-only, leaf-pinned `View` of this Run's full branch, from its triggering input back to the conversation root. This is the value to feed the model.
338
338
339
-
To rebuild the prior conversation for the model, drain `run.view` with `loadOlder()` (the sole history driver) for as much ancestor context as you want, then read `getMessages()`:
339
+
`run.view` includes an ancestor turn only once its run has completed. An ancestor that is still active, suspended, cancelled, or errored is omitted, along with the input it replied to, so a dangling tool call from a concurrent or interrupted turn can't invalidate the prompt. The current run is always included, and an omitted ancestor reappears once it completes.
340
+
341
+
To rebuild the prior conversation for the model, drain `run.view` with `loadOlder()` for as much ancestor context as you want, then read `getMessages()`:
340
342
341
343
<Code>
342
344
```javascript
343
-
awaitrun.start();
344
-
345
-
// Drain the branch back to the root for full context.
345
+
// Rebuild the conversation from run.view before run.start(): draining pages in
346
+
// this run's triggering input (otherwise run.start() awaits it arriving live).
Copy file name to clipboardExpand all lines: src/pages/docs/ai-transport/features/chain-of-thought.mdx
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@
2
2
title: "Chain of thought"
3
3
meta_description: "Stream reasoning and thinking content alongside responses with Ably AI Transport. Display chain-of-thought in real time."
4
4
meta_keywords: "chain of thought, reasoning, thinking, AI Transport, Ably, streaming reasoning"
5
-
intro: "Your users see the agent's reasoning as it streams, side by side with the response. AI Transport multiplexes reasoning and text streams within the same turn."
5
+
intro: "Your users see the agent's reasoning as it streams, side by side with the response. AI Transport multiplexes reasoning and text streams within the same Run."
6
6
redirect_from:
7
7
- /docs/ai-transport/messaging/chain-of-thought
8
8
---
9
9
10
-
Chain of thought streams reasoning content alongside the main response text. The codec supports multiple stream types within a single turn. Text and reasoning are delivered as separate streams that render independently in the UI.
10
+
Chain of thought streams reasoning content alongside the main response text. The codec supports multiple stream types within a single Run. Text and reasoning are delivered as separate streams that render independently in the UI.
11
11
12
12

intro: "Vercel AI SDK UI gives you clientside react hooks like useChat for building chat interfaces. AI Transport plugs into useChat as a ChatTransport, so the same UI gets durable sessions, multi-device sync, and bidirectional control."
5
+
intro: "Vercel AI SDK UI gives you client-side React hooks like useChat for building chat interfaces. AI Transport plugs into useChat as a ChatTransport, so the same UI gets durable sessions, multi-device sync, and bidirectional control."
0 commit comments