Skip to content

fix: use jsonSchema() wrapper and parameters key for AI SDK tool definitions#1742

Closed
justemu wants to merge 1 commit into
garrytan:masterfrom
justemu:pr/jsonSchema-fix-1739
Closed

fix: use jsonSchema() wrapper and parameters key for AI SDK tool definitions#1742
justemu wants to merge 1 commit into
garrytan:masterfrom
justemu:pr/jsonSchema-fix-1739

Conversation

@justemu

@justemu justemu commented Jun 1, 2026

Copy link
Copy Markdown

Problem

When agent.use_gateway_loop=true is enabled for non-Anthropic providers, subagent tool loops fail with schema is not a function.

Root Cause

gateway.chat() passes tool definitions to generateText() using inputSchema: { jsonSchema: t.inputSchema }. The Vercel AI SDK expects the parameters key with jsonSchema()-wrapped values. The inputSchema key is silently ignored for openai-compatible providers.

Fix

  • Import jsonSchema from the ai package
  • Replace inputSchema: { jsonSchema: t.inputSchema } with parameters: jsonSchema(t.inputSchema)

Testing

  • Build passes (1631 modules, zero errors)
  • Verified on upgraded v0.42.1.0 fork

Closes #1739

…finitions

The gateway.chat() function passed raw JSON Schema objects under the
'inputSchema' key to generateText(). The Vercel AI SDK expects tools to
use the 'parameters' key with jsonSchema()-wrapped values. The
'inputSchema' key is silently ignored for openai-compatible providers.

This causes non-Anthropic subagent tool loops (agent.use_gateway_loop=true)
to fail with:
  [chat(deepseek:...)] schema is not a function

because the SDK tries to call .schema() on whatever lands under
'parameters', which is undefined, falling through to a plain Object.

Fix:
- Import jsonSchema from 'ai'
- Replace inputSchema: { jsonSchema: ... } with parameters: jsonSchema(...)

Affected: all releases with agent.use_gateway_loop support (v0.38+).
@garrytan

garrytan commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Thanks for the diagnosis — closing in favor of #1809 (v0.42.19.0). One correction worth noting: this PR switches the key to parameters, which is the AI SDK v4 key. In v6 (ai@6.0.174) the tool field is inputSchema, and parameters is silently ignored, so it would drop the schema. The landed fix keeps inputSchema and wraps it with jsonSchema(). Crediting your independent diagnosis as Co-Author.

@garrytan garrytan closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-Anthropic subagent tool loops fail with 'schema is not a function'

2 participants