Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.
Similar patterns, and when each one is the better fit.

Multi-Step Tool PatternUse this when a chat agent must call several typed tools in a row, feeding each result into the next step, with a step limit to stop runaway loops.
HIL Needs ApprovalDemonstrate tool approval with async generators. Includes real-time feedback, approval workflows, and interactive management.
Tool ExecutionUse this when your chat app calls tools and you want each call's input, output, and status rendered inline as it streams.
Tool Input Lifecycle HooksUse this when you want UI state, like a spinner or progress label, to react to tool input starting, streaming, and becoming fully available.Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: OPENAI_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
OPENAI_API_KEYGet keyAI SDK APIs
streamTextconvertToModelMessagestooluseChatProviders
app/page.tsxapp/layout.tsxapp/api/tool-preliminary-results/route.tscomponents/preliminary-results-demo.tsxtools/weather.tstools/weather-ui.tsxnpm packages
7
Registry components
tools/weather.tsWeather tool demonstrating the preliminary tool results pattern using async generator (async *execute with yield). Yields intermediate status updates before the final result.
Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.
Similar patterns, and when each one is the better fit.

Multi-Step Tool PatternUse this when a chat agent must call several typed tools in a row, feeding each result into the next step, with a step limit to stop runaway loops.
HIL Needs ApprovalDemonstrate tool approval with async generators. Includes real-time feedback, approval workflows, and interactive management.
Tool ExecutionUse this when your chat app calls tools and you want each call's input, output, and status rendered inline as it streams.
Tool Input Lifecycle HooksUse this when you want UI state, like a spinner or progress label, to react to tool input starting, streaming, and becoming fully available.Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: OPENAI_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
OPENAI_API_KEYGet keyAI SDK APIs
streamTextconvertToModelMessagestooluseChatProviders
app/page.tsxapp/layout.tsxapp/api/tool-preliminary-results/route.tscomponents/preliminary-results-demo.tsxtools/weather.tstools/weather-ui.tsxnpm packages
7
Registry components
tools/weather.tsWeather tool demonstrating the preliminary tool results pattern using async generator (async *execute with yield). Yields intermediate status updates before the final result.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.