Skip to content

Commit d843cae

Browse files
committed
docs(ai-chat): changelog entry for 0.0.0-chat-prerelease-20260418174118
Covers chat.endRun(), finishReason on turn-complete events, user-initiated compaction pattern, and the new human-in-the-loop patterns page.
1 parent d19a3ff commit d843cae

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

docs/ai-chat/changelog.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,53 @@ sidebarTitle: "Changelog"
44
description: "Pre-release updates for AI chat agents."
55
---
66

7+
<Update label="April 18, 2026" description="0.0.0-chat-prerelease-20260418174118" tags={["SDK"]}>
8+
9+
## `chat.endRun()` — exit on your own terms
10+
11+
New imperative API to exit the loop after the current turn completes, without the upgrade-required signal that `chat.requestUpgrade()` sends. Use for one-shot agents, budget-exhausted exits, or goal-reached completions.
12+
13+
```ts
14+
chat.agent({
15+
id: "one-shot",
16+
run: async ({ messages, signal }) => {
17+
chat.endRun();
18+
return streamText({ model: openai("gpt-4o"), messages, abortSignal: signal });
19+
},
20+
});
21+
```
22+
23+
The current turn streams normally, `onBeforeTurnComplete` / `onTurnComplete` fire, the turn-complete chunk is written, and the run exits instead of suspending. Callable from `run()`, `chat.defer()`, `onBeforeTurnComplete`, or `onTurnComplete`. See [Ending a run on your terms](/ai-chat/backend#ending-a-run-on-your-terms).
24+
25+
## `finishReason` on turn-complete events
26+
27+
`TurnCompleteEvent` and `BeforeTurnCompleteEvent` now include the AI SDK's `finishReason` (`"stop" | "tool-calls" | "length" | "content-filter" | "error" | "other"`). Clean signal for distinguishing a normal turn end from one paused on a pending tool call (HITL flows like `ask_user`):
28+
29+
```ts
30+
onTurnComplete: async ({ finishReason, responseMessage }) => {
31+
if (finishReason === "tool-calls") {
32+
// Paused — assistant message has a pending tool call waiting for user input
33+
await persistCheckpoint(responseMessage);
34+
} else {
35+
await persistCompleted(responseMessage);
36+
}
37+
};
38+
```
39+
40+
Undefined for manual `chat.pipe()` flows or aborted streams. See the new [Human-in-the-loop pattern](/ai-chat/patterns/human-in-the-loop).
41+
42+
## User-initiated compaction pattern
43+
44+
The [Compaction guide](/ai-chat/compaction) now covers how to wire a "Summarize conversation" button or `/compact` slash command via `actionSchema` + `onAction`. The agent summarizes on demand, rewrites history with `chat.history.set()`, and short-circuits the LLM call for action turns.
45+
46+
Needed a small type fix for this: `ChatTaskPayload.trigger` now correctly includes `"action"`, so `run()` handlers can short-circuit with `if (trigger === "action") return` when an action doesn't need a response.
47+
48+
## Human-in-the-loop pattern page
49+
50+
New [Human-in-the-loop](/ai-chat/patterns/human-in-the-loop) page walks through `ask_user`-style mid-turn user input end-to-end: defining a no-execute tool, rendering pending tool calls on the frontend with `addToolOutput` + `sendAutomaticallyWhen`, detecting paused turns via `finishReason`, and two persistence strategies (overwrite vs. checkpoint nodes).
51+
52+
</Update>
53+
754
<Update label="April 18, 2026" description="0.0.0-chat-prerelease-20260418083610" tags={["SDK"]}>
855

956
## Offline test harness for `chat.agent`

0 commit comments

Comments
 (0)