Description
Zod internal properties (_def, ZodEffects, "zod", "preprocess", _cached, _ctx) leak into the serialized tool/function declaration JSON schema sent to LLM APIs. This causes 400 Invalid JSON payload errors when using providers that strictly validate JSON Schema (Google Gemini, Anthropic Claude via strict proxies).
Error Example
[400]: Invalid JSON payload received. Unknown name "_def" at
'request.tools[0].function_declarations[3].parameters.properties[0].value':
Cannot find field.
Full error from Antigravity Manager (Anthropic SDK -> Gemini):
Invalid value at 'request.tools[0].function_declarations[3].parameters...
.properties[0].value.properties[0].value.properties[1].value.type', "preprocess"
Invalid value at 'request.tools[0].function_declarations[3].parameters...
.properties[0].value.properties[0].value.properties[2].value', "ZodEffects"
Affected Providers
All AI SDK provider packages share @ai-sdk/core:
@ai-sdk/openai / @ai-sdk/openai-compatible -> same bug
@ai-sdk/google -> same bug
@ai-sdk/anthropic -> same bug
Working Providers
qw/* and cmd/* models (Qwen, GPT, DeepSeek, etc.) work because they accept extra fields silently.
Environment
- OpenCode Version: 1.14.33 (macOS .app bundle)
- AI SDK bundled inside:
/Applications/OpenCode.app/Contents/Resources/app.asar/out/main/chunks/node-DlUV59aW.js
- Error Source:
OpenAIResponsesLanguageModel3.doStream
Root Cause
@ai-sdk/core (bundled inside OpenCode.app) does not properly strip Zod internal properties when converting Zod schemas to JSON Schema for function declarations. The _def property and related Zod internals leak into the serialized payload. Updating the bundled AI SDK version should resolve this.
Description
Zod internal properties (
_def,ZodEffects,"zod","preprocess",_cached,_ctx) leak into the serialized tool/function declaration JSON schema sent to LLM APIs. This causes 400 Invalid JSON payload errors when using providers that strictly validate JSON Schema (Google Gemini, Anthropic Claude via strict proxies).Error Example
Full error from Antigravity Manager (Anthropic SDK -> Gemini):
Affected Providers
All AI SDK provider packages share
@ai-sdk/core:@ai-sdk/openai/@ai-sdk/openai-compatible-> same bug@ai-sdk/google-> same bug@ai-sdk/anthropic-> same bugWorking Providers
qw/*andcmd/*models (Qwen, GPT, DeepSeek, etc.) work because they accept extra fields silently.Environment
/Applications/OpenCode.app/Contents/Resources/app.asar/out/main/chunks/node-DlUV59aW.jsOpenAIResponsesLanguageModel3.doStreamRoot Cause
@ai-sdk/core(bundled inside OpenCode.app) does not properly strip Zod internal properties when converting Zod schemas to JSON Schema for function declarations. The_defproperty and related Zod internals leak into the serialized payload. Updating the bundled AI SDK version should resolve this.