feat(chat): accept TanStack AI streams in thread.post() - #934
Merged
Merged
Conversation
TanStack AI's chat() returns an async iterable of AG-UI events rather than
AI SDK stream parts. thread.post(), thread.reply() and channel.post() now
recognize both: TEXT_MESSAGE_CONTENT deltas become text, and each
TEXT_MESSAGE_END inserts a paragraph break between tool-loop turns, the
same way finish-step does for the AI SDK's fullStream.
import { chat } from "@tanstack/ai";
bot.onNewMention(async (thread, message) => {
const stream = chat({
adapter,
messages: [{ role: "user", content: message.text }],
});
await thread.post(stream);
});
Detection is duck-typed on the event type, so nothing is imported from
@tanstack/ai.
Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
bensabic
added this pull request to stack #937
September 15, 2026 07:06
The docs content test checks every import in an MDX code block against a list of known packages. The new TanStack examples import @tanstack/ai and @tanstack/ai-vercel-gateway. Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
TanStack only streams a structured-output run when stream: true is passed alongside outputSchema, so show the option in the note. Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
dancer
approved these changes
Sep 15, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
thread.post()already streams AI SDKfullStreamandtextStreamresults. This adds the same treatment for TanStack AI, whosechat()returns an async iterable of AG-UI events.TEXT_MESSAGE_CONTENTdeltas become text, and eachTEXT_MESSAGE_ENDinserts a paragraph break between tool-loop turns, mirroring howfinish-stepis handled for the AI SDK. Tool call, reasoning, run, and step events are skipped. Detection is duck-typed on the eventtype, so nothing is imported from@tanstack/ai. The same path servesthread.reply()andchannel.post().Structured-output runs (
chat({ outputSchema })) stream their JSON as text deltas, so they would post raw JSON. The docs call this out rather than special-casing it, matching how AI SDK structured output behaves today.Changed files:
StreamEventwidened with the AG-UI shapesThis is the bottom of a three-PR stack. The changeset here covers the whole stack, so the three should merge together.