fix(groq,google): suppress response format when tools are present#16540
Open
FrancoKaddour wants to merge 5 commits into
Open
fix(groq,google): suppress response format when tools are present#16540FrancoKaddour wants to merge 5 commits into
FrancoKaddour wants to merge 5 commits into
Conversation
…d server_error with zod v4
Recurse only through known JSON Schema structural keywords (properties, patternProperties, \, allOf, anyOf, etc.) instead of every object key. Prevents deletion of user-defined tool or response parameters whose name happens to be 'pattern'.
…jection
When a tool call's input is not valid JSON, the catch block fallback
stored toolCall.input (a raw string) directly as the tool call's input
field. On multi-turn conversations this raw string ends up in the
message history. Providers like Amazon Bedrock expect toolUse.input to
be a JSON object and reject the request with a format error on the
next turn.
Fix: when safeParseJSON fails, store { rawInvalidInput: toolCall.input }
so the field is always a JSON-serialisable object.
Fixes vercel#14442
Both Groq and Google APIs reject requests that combine a structured JSON response format (json_schema / application/json mime type) with function calling tools. generateText() with output + tools therefore threw a 400 on both providers. When tools are present they take precedence and the response format fields are cleared before the request is sent. Fixes vercel#10023
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.
Fixes #10023
Both Groq and Google APIs reject requests that combine a structured JSON response format with function calling tools:
Calling generateText() with both output (which sets responseFormat) and tools therefore throws a 400 on both providers.
Fix: In both providers, when tools are present they take precedence and the response format fields response_format for Groq, responseMimeTyperesponseSchema for Google) are omitted before the request is sent.