@ai-sdk/google 4.0.79 → 4.0.80

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.
@@ -103,6 +103,20 @@ function convertUrlToolResultPart(url) {
103
103
  }
104
104
  };
105
105
  }
106
+ function containsJSONSchemaReference(value) {
107
+ if (Array.isArray(value)) {
108
+ return value.some(containsJSONSchemaReference);
109
+ }
110
+ if (typeof value !== "object" || value === null) {
111
+ return false;
112
+ }
113
+ return Object.entries(value).some(
114
+ ([key, nestedValue]) => key === "$ref" || containsJSONSchemaReference(nestedValue)
115
+ );
116
+ }
117
+ function serializeFunctionResponseContent(value) {
118
+ return containsJSONSchemaReference(value) ? JSON.stringify(value) : value;
119
+ }
106
120
  function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
107
121
  const functionResponseParts = [];
108
122
  const responseTextParts = [];
@@ -511,7 +525,7 @@ function convertToGoogleMessages(prompt, options) {
511
525
  name: part.toolName,
512
526
  response: {
513
527
  name: part.toolName,
514
- content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
528
+ content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : serializeFunctionResponseContent(output.value)
515
529
  }
516
530
  }
517
531
  });