fix: use jsonSchema() wrapper and parameters key for AI SDK tool definitions#1742
Closed
justemu wants to merge 1 commit into
Closed
fix: use jsonSchema() wrapper and parameters key for AI SDK tool definitions#1742justemu wants to merge 1 commit into
justemu wants to merge 1 commit into
Conversation
…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+).
Owner
|
Thanks for the diagnosis — closing in favor of #1809 (v0.42.19.0). One correction worth noting: this PR switches the key to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
agent.use_gateway_loop=trueis enabled for non-Anthropic providers, subagent tool loops fail withschema is not a function.Root Cause
gateway.chat()passes tool definitions togenerateText()usinginputSchema: { jsonSchema: t.inputSchema }. The Vercel AI SDK expects theparameterskey withjsonSchema()-wrapped values. TheinputSchemakey is silently ignored for openai-compatible providers.Fix
jsonSchemafrom theaipackageinputSchema: { jsonSchema: t.inputSchema }withparameters: jsonSchema(t.inputSchema)Testing
Closes #1739