@ai-sdk/google 4.0.90 → 4.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -358,14 +358,17 @@ function convertToGoogleMessages(prompt, options) {
358
358
  if (output.type === "content") {
359
359
  if (supportsFunctionResponseParts) appendToolResultParts(parts, part.toolName, output.value, part.toolCallId, includeFunctionCallIds, supportedFunctionResponseUrls);
360
360
  else appendLegacyToolResultParts(parts, part.toolName, output.value, part.toolCallId, includeFunctionCallIds);
361
- } else parts.push({ functionResponse: {
362
- ...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
363
- name: part.toolName,
364
- response: {
361
+ } else {
362
+ const isError = output.type === "error-text" || output.type === "error-json" || output.type === "execution-denied";
363
+ parts.push({ functionResponse: {
364
+ ...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
365
365
  name: part.toolName,
366
- content: output.type === "execution-denied" ? output.reason ?? "Tool call execution denied." : serializeFunctionResponseContent(output.value)
367
- }
368
- } });
366
+ response: {
367
+ name: part.toolName,
368
+ ...isError ? { error: output.type === "execution-denied" ? output.reason ?? "Tool call execution denied." : serializeFunctionResponseContent(output.value) } : { content: serializeFunctionResponseContent(output.value) }
369
+ }
370
+ } });
371
+ }
369
372
  }
370
373
  contents.push({
371
374
  role: "user",