fix(gemini): fill empty tool schemas after $ref strip

Vertex rejects orphan {} left when $ref/$defs are removed from function declarations. Promote empty nodes to object+reason placeholder in addPlaceholders.
This commit is contained in:
Cokky Turnip
2026-07-29 19:31:15 +07:00
parent 0afe949387
commit e3e3e235f6
+13
View File
@@ -353,6 +353,19 @@ export function cleanJSONSchemaForAntigravity(schema) {
function addPlaceholders(obj) { function addPlaceholders(obj) {
if (!obj || typeof obj !== "object") return; if (!obj || typeof obj !== "object") return;
// Empty schema {} (no type, no properties) after $ref removal — treat as object with placeholder
if (Object.keys(obj).length === 0) {
obj.type = "object";
obj.properties = {
reason: {
type: "string",
description: "Brief explanation of why you are calling this tool"
}
};
obj.required = ["reason"];
return;
}
if (obj.type === "object") { if (obj.type === "object") {
if (!obj.properties || Object.keys(obj.properties).length === 0) { if (!obj.properties || Object.keys(obj.properties).length === 0) {
obj.properties = { obj.properties = {