Tool Call Repair
Repair invalid tool calls using experimental_repairToolCall. Fix schema validation errors without requiring additional steps that pollute message history.
View Full Pattern on Desktop

Problems Solved
- Repair invalid tool calls automatically
- Fix schema validation errors without additional steps
- Handle tool call failures gracefully
- Use structured outputs for repair
Use Cases
- Handling invalid tool calls from smaller models
- Repairing complex schema validation errors
- Automatic tool call error recovery
- Improving tool call success rate
AI SDK APIs
Tags
Requirements
- Node.js
- 18+
- Memory
- 512MB
- Other
- OpenAI API key
Environment Variables
OPENAI_API_KEYGet key →
External Services
Ready to use?
View the full interactive pattern with live preview and copy the source code.
View PatternView 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.


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


Tool API Context
Pass arbitrary context from generateText/streamText to tool execution via experimental_context. Access context in tool execute functions for dynamic behavior.


Dynamic Tool
Create dynamic tools with runtime-generated schemas using dynamicTool. Demonstrates unit conversion tools where schema adapts based on conversion type (temperature, length, weight, currency) and supports dynamic model selection.