Skip to content

Commit 1b3e05c

Browse files
committed
fix: simplify schema sanitization logic and re-enable tool sanitization in RequestHandler
1 parent af6832b commit 1b3e05c

2 files changed

Lines changed: 5 additions & 19 deletions

File tree

src/core/FormatConverter.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -286,31 +286,17 @@ class FormatConverter {
286286
// Helper function to recursively sanitize schema:
287287
// 1. Remove unsupported fields ($schema, additionalProperties)
288288
// 2. Convert lowercase type to uppercase (object -> OBJECT, string -> STRING, etc.)
289-
const sanitizeSchema = (obj, isPropertiesMap = false) => {
289+
const sanitizeSchema = obj => {
290290
if (!obj || typeof obj !== "object") return obj;
291291

292292
const result = Array.isArray(obj) ? [] : {};
293293

294294
for (const key of Object.keys(obj)) {
295-
// Skip fields not supported by Gemini API
296-
const unsupportedKeys = [
297-
"$schema",
298-
"additionalProperties",
299-
"ref",
300-
"$ref",
301-
"propertyNames",
302-
"patternProperties",
303-
"unevaluatedProperties",
304-
];
305-
if (!isPropertiesMap && unsupportedKeys.includes(key)) {
306-
continue;
307-
}
308-
309295
if (key === "type" && typeof obj[key] === "string") {
310296
// Convert lowercase type to uppercase for Gemini
311297
result[key] = obj[key].toUpperCase();
312298
} else if (typeof obj[key] === "object" && obj[key] !== null) {
313-
result[key] = sanitizeSchema(obj[key], key === "properties");
299+
result[key] = sanitizeSchema(obj[key]);
314300
} else {
315301
result[key] = obj[key];
316302
}

src/core/RequestHandler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4137,9 +4137,9 @@ class RequestHandler {
41374137
if (bodyObj.contents) {
41384138
this.formatConverter.ensureThoughtSignature(bodyObj);
41394139
}
4140-
// if (bodyObj.tools) {
4141-
// this.formatConverter.sanitizeGeminiTools(bodyObj);
4142-
// }
4140+
if (bodyObj.tools) {
4141+
this.formatConverter.sanitizeGeminiTools(bodyObj);
4142+
}
41434143
}
41444144

41454145
// Force web search and URL context for native Google requests

0 commit comments

Comments
 (0)