Tool Input Lifecycle Hooks
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.
Problems solved
- Observe tool input generation with onInputStart
- Stream partial tool arguments via onInputDelta
- React when full tool input becomes available with onInputAvailable
Use cases
- Debugging streaming tool argument construction
- UI spinners tied to tool input lifecycle events
- Teaching AI SDK tool input hooks
- Monitoring long tool-argument generation
Setup
Requirements, wiring steps, and what this pattern adds to your project.
Getting started
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
- 1
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).
- 2
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
- 3
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: OPENAI_API_KEY.
- 4
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
- 5
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.
Environment variables
OPENAI_API_KEYGet key
Capabilities
AI SDK APIs
streamTextconvertToModelMessagestooluseChatonInputStartonInputDeltaonInputAvailableProviders
Files added
6 filesapp/page.tsxapp/layout.tsxapp/api/tool-input-lifecycle/route.tscomponents/input-lifecycle-demo.tsxtools/weather.tstools/weather-ui.tsx
Dependencies
14 totalnpm packages
7
Registry components
Critical files
tools/weather.tsWeather tool demonstrating all three tool input lifecycle hooks: onInputStart, onInputDelta, and onInputAvailable. Core pattern for monitoring tool input generation.
Requirements
- Complexity
- Beginner
- Setup time
- ~5 minutes
- Node
- 24+
- Memory
- 512MB









