Skip to main content
Normalizes an async iterable stream for use with thread.post(). Handles these stream types automatically:
  • Text streams (AsyncIterable<string>, e.g. AI SDK textStream) — passed through as-is.
  • AI SDK full streams (AsyncIterable<object>, e.g. result.fullStream) — extracts text-delta events and injects "\n\n" separators after each finish-step so that multi-step agent output reads naturally.
  • TanStack AI / AG-UI streams (AsyncIterable<StreamChunk> from chat()) — extracts TEXT_MESSAGE_CONTENT deltas and injects "\n\n" separators after each TEXT_MESSAGE_END, since every model turn in the tool loop is its own text message.
  • StreamChunk objects (task_update, plan_update, markdown_text) — passed through as-is for adapters with native structured chunk support.
This is used internally by thread.post(), so you can pass any of these streams directly:

Parameters

AsyncIterable<unknown>
required

Returns

StreamChunk