diff --git a/src/plugin/tools.ts b/src/plugin/tools.ts index 83f95b4..372bce9 100644 --- a/src/plugin/tools.ts +++ b/src/plugin/tools.ts @@ -40,6 +40,10 @@ export function sanitizeFunctionParameters(params: any): any { ) continue; const val = params[key]; + // GigaChat API only accepts format "date", "date-time" or "time". + // Other JSON Schema formats (e.g. "uri" used by webfetch) cause 422. + if (key === "format" && !["date", "date-time", "time"].includes(val)) + continue; if (key === "properties" && val !== null && typeof val === "object") { out[key] = {}; for (const propKey of Object.keys(val)) { diff --git a/src/plugin/translation.test.ts b/src/plugin/translation.test.ts index 44d6fa4..be51267 100644 --- a/src/plugin/translation.test.ts +++ b/src/plugin/translation.test.ts @@ -22,6 +22,28 @@ describe("GigaChat Request Translator", () => { expect(stringifyArguments(null)).toBe("{}"); }); + it("drops unsupported JSON Schema format values (422 guard) but keeps date/time", () => { + expect( + sanitizeFunctionParameters({ + type: "object", + properties: { + url: { type: "string", format: "uri" }, + created: { type: "string", format: "date-time" }, + day: { type: "string", format: "date" }, + clock: { type: "string", format: "time" }, + }, + }), + ).toEqual({ + type: "object", + properties: { + url: { type: "string" }, + created: { type: "string", format: "date-time" }, + day: { type: "string", format: "date" }, + clock: { type: "string", format: "time" }, + }, + }); + }); + it("rejects an upload response without a usable file ID", async () => { const post = vi.spyOn(axios, "post").mockResolvedValue({ data: {} }); try {