fix: add transform case for gemini if mcp tool has missing array items (#5846)

thinking-toggle-wip
lif 2025-12-21 01:41:52 +08:00 committed by Aiden Cline
parent 2d47d5cf83
commit b1e7975bf8
2 changed files with 28 additions and 0 deletions

View File

@ -457,6 +457,10 @@ export namespace ProviderTransform {
result.required = result.required.filter((field: any) => field in result.properties)
}
if (result.type === "array" && result.items == null) {
result.items = {}
}
return result
}

View File

@ -167,6 +167,30 @@ describe("ProviderTransform.maxOutputTokens", () => {
})
})
describe("ProviderTransform.schema - gemini array items", () => {
test("adds missing items for array properties", () => {
const geminiModel = {
providerID: "google",
api: {
id: "gemini-3-pro",
},
} as any
const schema = {
type: "object",
properties: {
nodes: { type: "array" },
edges: { type: "array", items: { type: "string" } },
},
} as any
const result = ProviderTransform.schema(geminiModel, schema) as any
expect(result.properties.nodes.items).toBeDefined()
expect(result.properties.edges.items.type).toBe("string")
})
})
describe("ProviderTransform.message - DeepSeek reasoning content", () => {
test("DeepSeek with tool calls includes reasoning_content in providerOptions", () => {
const msgs = [