





















@@ -13,7 +13,6 @@ import {
1313wrapToolWithBeforeToolCallHook,
1414} from "./agent-tools.before-tool-call.js";
1515import {
16-cleanToolSchemaForGemini,
1716normalizeToolParameterSchema,
1817normalizeToolParameters,
1918} from "./agent-tools.schema.js";
@@ -136,15 +135,18 @@ describe("normalizeToolParameterSchema", () => {
136135});
137136138137it("inlines local $ref before removing unsupported keywords", () => {
139-const cleaned = cleanToolSchemaForGemini({
140-type: "object",
141-properties: {
142-foo: { $ref: "#/$defs/Foo" },
143-},
144-$defs: {
145-Foo: { type: "string", enum: ["a", "b"] },
138+const cleaned = normalizeToolParameterSchema(
139+{
140+type: "object",
141+properties: {
142+foo: { $ref: "#/$defs/Foo" },
143+},
144+$defs: {
145+Foo: { type: "string", enum: ["a", "b"] },
146+},
146147},
147-}) as {
148+{ modelProvider: "gemini" },
149+) as {
148150$defs?: unknown;
149151properties?: Record<string, unknown>;
150152};
@@ -600,18 +602,21 @@ describe("normalizeToolParameterSchema", () => {
600602});
601603602604it("cleans tuple items schemas", () => {
603-const cleaned = cleanToolSchemaForGemini({
604-type: "object",
605-properties: {
606-tuples: {
607-type: "array",
608-items: [
609-{ type: "string", format: "uuid" },
610-{ type: "number", minimum: 1 },
611-],
605+const cleaned = normalizeToolParameterSchema(
606+{
607+type: "object",
608+properties: {
609+tuples: {
610+type: "array",
611+items: [
612+{ type: "string", format: "uuid" },
613+{ type: "number", minimum: 1 },
614+],
615+},
612616},
613617},
614-}) as {
618+{ modelProvider: "gemini" },
619+) as {
615620properties?: Record<string, unknown>;
616621};
617622@@ -625,13 +630,16 @@ describe("normalizeToolParameterSchema", () => {
625630});
626631627632it("drops null-only union variants without flattening other unions", () => {
628-const cleaned = cleanToolSchemaForGemini({
629-type: "object",
630-properties: {
631-parentId: { anyOf: [{ type: "string" }, { type: "null" }] },
632-count: { oneOf: [{ type: "string" }, { type: "number" }] },
633+const cleaned = normalizeToolParameterSchema(
634+{
635+type: "object",
636+properties: {
637+parentId: { anyOf: [{ type: "string" }, { type: "null" }] },
638+count: { oneOf: [{ type: "string" }, { type: "number" }] },
639+},
633640},
634-}) as {
641+{ modelProvider: "gemini" },
642+) as {
635643properties?: Record<string, unknown>;
636644};
637645此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。