ai
semver
>=7.0.0postconditions1functions1last verified2026-06-25coverage score94%Postconditions: what we check
- tool · tool-context-schema-validationerrorWhentool() call is made with a contextSchema and the caller-supplied toolsContext (passed to generateText / streamText / ToolLoopAgent) fails validation against that schema. New in v7.0.0 (CHANGELOG f319fde): prior versions declared contextSchema but silently skipped validation. TypeValidationError includes the tool name and failing context in error.context, making it diagnosable. Common trigger: mismatched types between the tool server's contextSchema definition and the runtime context object built by the caller.Throws
TypeValidationError (AI_TypeValidationError from @ai-sdk/provider) with tool-context metadata in error.contextRequired handlingCaller MUST wrap generateText() / streamText() / ToolLoopAgent.generate() / ToolLoopAgent.stream() calls in try-catch when using tools with contextSchema. Use TypeValidationError.isInstance(error) to distinguish from schema-validation errors thrown by generateObject(). Inspect error.context for the specific tool name and failing context value to produce a useful error message. Do NOT catch TypeValidationError silently and continue — this is a programming error (type mismatch between tool definition and call site), not a transient error. Fail fast and fix the context construction.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
Sources
Every postcondition cites at least one of these. Grouped by source type; numbered to match the footnotes above.
Official documentation
- [2]ai-sdk.dev/docs/reference/ai-sdk-errorsAi Sdk Errors
Changelog & releases
- [1]github.com/vercel/ai/blobvercel/ai · CHANGELOG.md
Need a different package?
Request a profile