Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/plugin/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
22 changes: 22 additions & 0 deletions src/plugin/translation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down