VersionsEach version has its own postconditions. APIs and error modes shift across majors.
Profiles·Public

ai

semver>=7.0.0postconditions1functions1last verified2026-06-25coverage score94%

Postconditions: what we check

  • tool · tool-context-schema-validation
    error
    Whentool() 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.
    ThrowsTypeValidationError (AI_TypeValidationError from @ai-sdk/provider) with tool-context metadata in error.context
    Required 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[1][2]

Sources

Every postcondition cites at least one of these. Grouped by source type; numbered to match the footnotes above.

Official documentation
Changelog & releases
Need a different package?
Request a profile