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
Custom chat agent loops get two ergonomic wins for owning the turn loop.
6
+
7
+
`chat.writeTurnComplete()` now returns the turn boundary's resume cursors (`lastEventId` for the output stream and `sessionInEventId` for the input stream), so you can persist them straight from the task instead of round-tripping them back from the client.
`chat.pipeAndCapture()` no longer throws when a stream is stopped or fails. It now returns a `PipeAndCaptureResult` whose `message` holds any partial output captured before the stop or failure, alongside a typed `status` (`"complete" | "aborted" | "error"`) and, on failure, the `error`. Read the message off the result:
15
+
16
+
```ts
17
+
const { message, status, error } =awaitchat.pipeAndCapture(result, { signal });
18
+
if (message) conversation.addResponse(message);
19
+
if (status==="error") logger.error("turn failed", { error });
20
+
```
21
+
22
+
Note: `pipeAndCapture` previously resolved to `UIMessage | undefined`. Update call sites to read `.message` from the returned result.
0 commit comments