fix(ai): preserve CCA literal payloads

(cherry picked from commit b026a96326e3d7df89771f3224476dc37eeeaa9c)
This commit is contained in:
usr-bin-roygbiv
2026-07-28 10:46:36 +00:00
committed by can1357
parent 05d5b8c12d
commit 2ee5a10923
2 changed files with 85 additions and 50 deletions
@@ -233,6 +233,27 @@ describe("normalizeSchemaForGoogle", () => {
});
});
it("keeps CCA incompatibility passes out of literal defaults", () => {
const literal = {
nullable: true,
allOf: [{ type: "object" }],
oneOf: [{ type: "string" }, { type: "number" }],
};
expect(
normalizeSchemaForCCA({
type: "object",
properties: {
value: { oneOf: [{ type: "string" }, { type: "string" }] },
},
default: literal,
}),
).toEqual({
type: "object",
properties: { value: { type: "string" } },
default: literal,
});
});
it("sets object type while removing an object-valued enum converted from const", () => {
const sanitized = normalizeSchemaForGoogle({
const: { a: 1 },