fix: scrub tuple items schemas for Gemini tools (#926) — thanks @grp06
Co-authored-by: George Pickett <gpickett00@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
- Docs: document DM history limits for channel DMs. (#883) — thanks @pkrmf.
|
- Docs: document DM history limits for channel DMs. (#883) — thanks @pkrmf.
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
- Agents: scrub tuple `items` schemas for Gemini tool calls. (#926, fixes #746) — thanks @grp06.
|
||||||
- Embedded runner: suppress raw API error payloads from replies. (#924) — thanks @grp06.
|
- Embedded runner: suppress raw API error payloads from replies. (#924) — thanks @grp06.
|
||||||
- Auth: normalize Claude Code CLI profile mode to oauth and auto-migrate config. (#855) — thanks @sebslight.
|
- Auth: normalize Claude Code CLI profile mode to oauth and auto-migrate config. (#855) — thanks @sebslight.
|
||||||
- Sandbox: restore `docker.binds` config validation for custom bind mounts. (#873) — thanks @akonyer.
|
- Sandbox: restore `docker.binds` config validation for custom bind mounts. (#873) — thanks @akonyer.
|
||||||
|
|||||||
@@ -156,6 +156,30 @@ describe("createClawdbotCodingTools", () => {
|
|||||||
enum: ["a", "b"],
|
enum: ["a", "b"],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("cleans tuple items schemas", () => {
|
||||||
|
const cleaned = __testing.cleanToolSchemaForGemini({
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
tuples: {
|
||||||
|
type: "array",
|
||||||
|
items: [
|
||||||
|
{ type: "string", format: "uuid" },
|
||||||
|
{ type: "number", minimum: 1 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}) as {
|
||||||
|
properties?: Record<string, unknown>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const tuples = cleaned.properties?.tuples as { items?: unknown } | undefined;
|
||||||
|
const items = Array.isArray(tuples?.items) ? tuples?.items : [];
|
||||||
|
const first = items[0] as { format?: unknown } | undefined;
|
||||||
|
const second = items[1] as { minimum?: unknown } | undefined;
|
||||||
|
|
||||||
|
expect(first?.format).toBeUndefined();
|
||||||
|
expect(second?.minimum).toBeUndefined();
|
||||||
|
});
|
||||||
it("drops null-only union variants without flattening other unions", () => {
|
it("drops null-only union variants without flattening other unions", () => {
|
||||||
const cleaned = __testing.cleanToolSchemaForGemini({
|
const cleaned = __testing.cleanToolSchemaForGemini({
|
||||||
type: "object",
|
type: "object",
|
||||||
|
|||||||
@@ -280,8 +280,16 @@ function cleanSchemaForGeminiWithDefs(
|
|||||||
cleanSchemaForGeminiWithDefs(v, nextDefs, refStack),
|
cleanSchemaForGeminiWithDefs(v, nextDefs, refStack),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
} else if (key === "items" && value && typeof value === "object") {
|
} else if (key === "items" && value) {
|
||||||
cleaned[key] = cleanSchemaForGeminiWithDefs(value, nextDefs, refStack);
|
if (Array.isArray(value)) {
|
||||||
|
cleaned[key] = value.map((entry) =>
|
||||||
|
cleanSchemaForGeminiWithDefs(entry, nextDefs, refStack),
|
||||||
|
);
|
||||||
|
} else if (typeof value === "object") {
|
||||||
|
cleaned[key] = cleanSchemaForGeminiWithDefs(value, nextDefs, refStack);
|
||||||
|
} else {
|
||||||
|
cleaned[key] = value;
|
||||||
|
}
|
||||||
} else if (key === "anyOf" && Array.isArray(value)) {
|
} else if (key === "anyOf" && Array.isArray(value)) {
|
||||||
cleaned[key] =
|
cleaned[key] =
|
||||||
cleanedAnyOf ??
|
cleanedAnyOf ??
|
||||||
|
|||||||
Reference in New Issue
Block a user