tool( )





Pattern
Tool Call Repair
Repair invalid tool calls using experimental_repairToolCall. Fix schema validation errors without requiring additional steps that pollute message history.
IntermediateNov 2025View the full pattern on desktop


Problems solved
- Repair malformed tool calls before retrying execution
- Fix schema validation errors with generateObject
- Avoid polluting message history with extra repair turns
- Stream repair metadata to the client as data parts
Use cases
- Agents using smaller models that misformat tool args
- Complex Zod schemas that fail first-pass validation
- Automatic tool-call error recovery
- Improving tool success rates in production agents
AI SDK APIs
streamTextconvertToModelMessagestool(useChatexperimental_repairToolCallgenerateObjectNoSuchToolError
Tags
aitoolstool-call-repairexperimental-repairToolCallschema-validationerror-handlingai-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 β


Preliminary Tool Results
Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.
aitools+6
View pattern β



