Vercel has released updates to its AI SDK, with version 7.0.101 of the ai package and version 4.0.70 of the @ai-sdk/google package. These updates address specific issues related to tool output serialization and interaction with Google's Gemini models.
Key Points
- The
ai@7.0.101package includes a fix for serializing tool output JSON values. - The
@ai-sdk/google@4.0.70package now preserves JSON Schema instead of converting it to OpenAPI schema. - A fix in
@ai-sdk/google@4.0.70ensures thatfunctionResponse.responseremains an object for Gemini models. - Gemini's
google.protobuf.Structfield expects an object, and non-object tool results previously caused socket closures. - Non-object tool results are now wrapped under an
outputkey as prescribed by the field's documentation.
Context
According to the Vercel AI SDK Changelog, the ai@7.0.101 patch specifically fixes how tool output JSON values are serialized. For the @ai-sdk/google@4.0.70 package, two fixes were implemented: one to preserve JSON Schema directly rather than converting it to OpenAPI schema, and another to ensure that the functionResponse.response field remains an object. This latter fix addresses an issue where Gemini models, which type this field as a google.protobuf.Struct expecting an object, would close the socket if a string, number, array, or null tool result was sent unwrapped.
Why It Matters
These updates enhance the reliability and correctness of tool usage within applications built with the Vercel AI SDK, particularly when interacting with Google's Gemini models. Builders can expect more stable tool call execution and accurate schema handling, reducing unexpected disconnections or data transformation errors.
What To Do
- Note the update to
ai@7.0.101for improved tool output serialization. - If using Google models, update to
@ai-sdk/google@4.0.70to benefit from JSON Schema preservation. - Test tool calls with Gemini models after updating to
@ai-sdk/google@4.0.70to confirm stablefunctionResponse.responsehandling. - Observe how non-object tool results are now wrapped under an
outputkey when interacting with Gemini.
