chore(deadcode): remove duplicate Gemini schema helper

This commit is contained in:
Vincent Koc
2026-06-21 02:09:19 +08:00
parent 62b2e9ef14
commit 1f1b1aee6b
3 changed files with 34 additions and 35 deletions
+33 -25
View File
@@ -13,7 +13,6 @@ import {
wrapToolWithBeforeToolCallHook,
} from "./agent-tools.before-tool-call.js";
import {
cleanToolSchemaForGemini,
normalizeToolParameterSchema,
normalizeToolParameters,
} from "./agent-tools.schema.js";
@@ -136,15 +135,18 @@ describe("normalizeToolParameterSchema", () => {
});
it("inlines local $ref before removing unsupported keywords", () => {
const cleaned = cleanToolSchemaForGemini({
type: "object",
properties: {
foo: { $ref: "#/$defs/Foo" },
const cleaned = normalizeToolParameterSchema(
{
type: "object",
properties: {
foo: { $ref: "#/$defs/Foo" },
},
$defs: {
Foo: { type: "string", enum: ["a", "b"] },
},
},
$defs: {
Foo: { type: "string", enum: ["a", "b"] },
},
}) as {
{ modelProvider: "gemini" },
) as {
$defs?: unknown;
properties?: Record<string, unknown>;
};
@@ -600,18 +602,21 @@ describe("normalizeToolParameterSchema", () => {
});
it("cleans tuple items schemas", () => {
const cleaned = cleanToolSchemaForGemini({
type: "object",
properties: {
tuples: {
type: "array",
items: [
{ type: "string", format: "uuid" },
{ type: "number", minimum: 1 },
],
const cleaned = normalizeToolParameterSchema(
{
type: "object",
properties: {
tuples: {
type: "array",
items: [
{ type: "string", format: "uuid" },
{ type: "number", minimum: 1 },
],
},
},
},
}) as {
{ modelProvider: "gemini" },
) as {
properties?: Record<string, unknown>;
};
@@ -625,13 +630,16 @@ describe("normalizeToolParameterSchema", () => {
});
it("drops null-only union variants without flattening other unions", () => {
const cleaned = cleanToolSchemaForGemini({
type: "object",
properties: {
parentId: { anyOf: [{ type: "string" }, { type: "null" }] },
count: { oneOf: [{ type: "string" }, { type: "number" }] },
const cleaned = normalizeToolParameterSchema(
{
type: "object",
properties: {
parentId: { anyOf: [{ type: "string" }, { type: "null" }] },
count: { oneOf: [{ type: "string" }, { type: "number" }] },
},
},
}) as {
{ modelProvider: "gemini" },
) as {
properties?: Record<string, unknown>;
};
-8
View File
@@ -92,11 +92,3 @@ export function normalizeToolParameters(
parameters,
});
}
/**
* @deprecated Use normalizeToolParameters with modelProvider instead.
* This function should only be used for Gemini providers.
*/
export function cleanToolSchemaForGemini(schema: Record<string, unknown>): unknown {
return normalizeToolParameterSchema(schema, { modelProvider: "gemini" });
}
+1 -2
View File
@@ -59,7 +59,7 @@ import {
wrapToolWorkspaceRootGuardWithOptions,
wrapToolParamValidation,
} from "./agent-tools.read.js";
import { cleanToolSchemaForGemini, normalizeToolParameters } from "./agent-tools.schema.js";
import { normalizeToolParameters } from "./agent-tools.schema.js";
import type { AnyAgentTool } from "./agent-tools.types.js";
import { createApplyPatchTool } from "./apply-patch.js";
import type { AuthProfileStore } from "./auth-profiles/types.js";
@@ -409,7 +409,6 @@ export { resolveToolLoopDetectionConfig } from "./tool-loop-detection-config.js"
/** Test-only access to internal tool assembly helpers. */
export const testing = {
cleanToolSchemaForGemini,
getToolParamsRecord,
wrapToolParamValidation,
assertRequiredParams,