fix(antigravity): strip optional from tool schemas before Gemini
Closes #1537, #1841 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,7 +19,7 @@ export const UNSUPPORTED_SCHEMA_CONSTRAINTS = [
|
|||||||
// Dependency keywords (not supported)
|
// Dependency keywords (not supported)
|
||||||
"dependencies", "dependentSchemas", "dependentRequired",
|
"dependencies", "dependentSchemas", "dependentRequired",
|
||||||
// Other unsupported keywords
|
// Other unsupported keywords
|
||||||
"title", "if", "then", "else", "contentMediaType", "contentEncoding",
|
"title", "optional", "if", "then", "else", "contentMediaType", "contentEncoding",
|
||||||
// UI/Styling properties (from Cursor tools - NOT JSON Schema standard)
|
// UI/Styling properties (from Cursor tools - NOT JSON Schema standard)
|
||||||
"cornerRadius", "fillColor", "fontFamily", "fontSize", "fontWeight",
|
"cornerRadius", "fillColor", "fontFamily", "fontSize", "fontWeight",
|
||||||
"gap", "padding", "strokeColor", "strokeThickness", "textColor"
|
"gap", "padding", "strokeColor", "strokeThickness", "textColor"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { describe, it, expect } from "vitest";
|
|||||||
import "./registerAll.js";
|
import "./registerAll.js";
|
||||||
import { translateRequest } from "../../open-sse/translator/index.js";
|
import { translateRequest } from "../../open-sse/translator/index.js";
|
||||||
import { FORMATS } from "../../open-sse/translator/formats.js";
|
import { FORMATS } from "../../open-sse/translator/formats.js";
|
||||||
|
import { AntigravityExecutor } from "../../open-sse/executors/antigravity.js";
|
||||||
|
|
||||||
const AG2O = (req) =>
|
const AG2O = (req) =>
|
||||||
translateRequest(FORMATS.ANTIGRAVITY, FORMATS.OPENAI, "m", { request: req }, true, null, null);
|
translateRequest(FORMATS.ANTIGRAVITY, FORMATS.OPENAI, "m", { request: req }, true, null, null);
|
||||||
@@ -52,3 +53,32 @@ describe("Antigravity → OpenAI", () => {
|
|||||||
expect(hasEmpty, "empty text part emitted").toBe(false);
|
expect(hasEmpty, "empty text part emitted").toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Antigravity executor", () => {
|
||||||
|
it("strips optional from nested tool schemas", () => {
|
||||||
|
const out = new AntigravityExecutor().transformRequest("gemini-2.5-pro", {
|
||||||
|
request: {
|
||||||
|
contents: [{ role: "user", parts: [{ text: "hi" }] }],
|
||||||
|
tools: [{
|
||||||
|
functionDeclarations: [{
|
||||||
|
name: "lookup",
|
||||||
|
description: "Lookup a value",
|
||||||
|
parameters: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
query: {
|
||||||
|
type: "string",
|
||||||
|
description: "Search query",
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
}, true, { projectId: "project-1", connectionId: "conn-1" });
|
||||||
|
|
||||||
|
const query = out.request.tools[0].functionDeclarations[0].parameters.properties.query;
|
||||||
|
expect(query).toEqual({ type: "string", description: "Search query" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user