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


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
OPENAI_API_KEYGet key
External services
openai
Ready to use?
View the full interactive pattern with live preview and copy the source code.
View the pattern on desktopRelated patterns


Tool Input Lifecycle Hooks
Explore tool input lifecycle hooks: onInputStart, onInputDelta, and onInputAvailable. See how to track tool input generation in real-time during streaming.
aitools+7
View pattern β


Tool API Context
Pass arbitrary context from generateText/streamText to tool execution via experimental_context. Access context in tool execute functions for dynamic behavior.
aitools+5
View pattern β



