tool( )

Pattern

Preliminary Tool Results

Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.

BeginnerNov 2025View the full pattern on desktop
Preliminary Tool Results preview

Problems solved

  • Yield intermediate tool status with async generator execute
  • Show progressive tool updates before the final result
  • Keep users informed during long-running tool work

Use cases

  • Weather or lookup tools with staged status
  • Long-running enrichment operations
  • Progressive tool result UIs
  • Teaching async iterable tool execute patterns

AI SDK APIs

streamTextconvertToModelMessagestool(useChatasync-generator

Tags

aitoolspreliminary-resultsasync-iterablesgenerator-functionsstreamingai-sdktool-api

Requirements

Node.js
24+
Memory
512MB
Other
  • OpenAI API key

Environment variables

External services

openai

Ready to use?

View the full interactive pattern with live preview and copy the source code.

View the pattern on desktop

Related patterns