Root Cause Found
tool() sets the schema on .parameters, but prepareToolsAndToolChoice and doParseToolCall read .inputSchema — which is undefined. This causes all tool schemas to fall through to the empty default {"properties":{},"additionalProperties":false}.
One-line fix in two locations in ai/dist/index.mjs:
- inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
+ inputSchema: await asSchema(tool2.inputSchema ?? tool2.parameters).jsonSchema,
- const schema = asSchema3(tool2.inputSchema);
+ const schema = asSchema3(tool2.inputSchema ?? tool2.parameters);
How We Found It
const { tool } = require('ai');
const z = require('zod');
const t = tool({ description: 'test', parameters: z.object({ q: z.string() }), execute: async () => {} });
console.log(Object.keys(t)); // ['description', 'parameters', 'execute']
console.log(t.inputSchema); // undefined
console.log(typeof t.parameters); // object (zod schema)
tool() stores the zod schema on parameters. But prepareToolsAndToolChoice (line 1779) reads tool2.inputSchema which doesn't exist → asSchema(undefined) → returns the empty fallback {"properties":{},"additionalProperties":false}.
Similarly, doParseToolCall (line 3714) uses asSchema3(tool2.inputSchema) for validation → empty schema → validation against empty schema either fails or produces wrong results.
Impact
This breaks ALL tool calling for ALL providers when using tool() with Zod schemas in AI SDK v6. The model receives no parameter information, so:
- It guesses parameter names (sometimes
query, sometimes q, sometimes {})
- Even when the model guesses correctly,
doParseToolCall validates against the empty schema and may reject valid inputs
Verification
With the patch applied:
- API receives correct tool schema with all properties
- Model returns correct arguments 100% of the time
parseToolCall validates and passes correctly
- 8/10 → limited only by model non-determinism, not SDK bugs
Without the patch: 0/10 — every tool call gets empty schema, model guesses, SDK rejects.
Environment
ai: 6.0.116
zod: 4.3.6
- Tested with: Cloudflare Workers AI,
@ai-sdk/openai-compatible
- Both
streamText and generateText affected
Previous Report (Updated)
The original report described two separate bugs. After investigation, both symptoms trace to this single root cause:
- "Empty schema sent to API" →
tool2.inputSchema is undefined, fallback produces {}
- "SDK drops valid tool arguments" →
doParseToolCall validates against empty schema, marks calls as invalid or produces wrong parsed values
The streaming-specific arguments: "{}" from Cloudflare was a red herring — it only happened because the empty schema gave the model no parameter guidance. With the correct schema, Cloudflare's streaming endpoint also returns correct arguments.
Related
This likely supersedes #12020 ("AI SDK v6 + Zod: Tool input_schema is empty when using Anthropic") — same root cause.
Root Cause Found
tool()sets the schema on.parameters, butprepareToolsAndToolChoiceanddoParseToolCallread.inputSchema— which isundefined. This causes all tool schemas to fall through to the empty default{"properties":{},"additionalProperties":false}.One-line fix in two locations in
ai/dist/index.mjs:How We Found It
tool()stores the zod schema onparameters. ButprepareToolsAndToolChoice(line 1779) readstool2.inputSchemawhich doesn't exist →asSchema(undefined)→ returns the empty fallback{"properties":{},"additionalProperties":false}.Similarly,
doParseToolCall(line 3714) usesasSchema3(tool2.inputSchema)for validation → empty schema → validation against empty schema either fails or produces wrong results.Impact
This breaks ALL tool calling for ALL providers when using
tool()with Zod schemas in AI SDK v6. The model receives no parameter information, so:query, sometimesq, sometimes{})doParseToolCallvalidates against the empty schema and may reject valid inputsVerification
With the patch applied:
parseToolCallvalidates and passes correctlyWithout the patch: 0/10 — every tool call gets empty schema, model guesses, SDK rejects.
Environment
ai: 6.0.116zod: 4.3.6@ai-sdk/openai-compatiblestreamTextandgenerateTextaffectedPrevious Report (Updated)
The original report described two separate bugs. After investigation, both symptoms trace to this single root cause:
tool2.inputSchemais undefined, fallback produces{}doParseToolCallvalidates against empty schema, marks calls as invalid or produces wrong parsed valuesThe streaming-specific
arguments: "{}"from Cloudflare was a red herring — it only happened because the empty schema gave the model no parameter guidance. With the correct schema, Cloudflare's streaming endpoint also returns correct arguments.Related
This likely supersedes #12020 ("AI SDK v6 + Zod: Tool input_schema is empty when using Anthropic") — same root cause.