From eaf979a444d29fc5e09da13027d5bf3168c9d68c Mon Sep 17 00:00:00 2001 From: MATHEUS PATO Date: Wed, 12 Aug 2026 05:28:35 -0300 Subject: [PATCH] fix: add gemini-omni-flash-preview alias + fix tool schema loss Two bugs fixed: 1. Model 404: 'gemini-omni-flash-preview' was not in MODEL_ALIASES, causing fallback to raw model name which Google API rejects (404). Added mapping to gemini-3-flash (the actual API model name). 2. Tool schema missing (toolDebugMissing: 1): normalizeGeminiTools() created a 'custom' wrapper with input_schema but deleted it at line 332 without ensuring function.input_schema was set first. Now function.input_schema is always populated before custom is stripped, and a fallback empty schema is added if source had none. --- src/plugin/transform/gemini.ts | 11 ++++++++++- src/plugin/transform/model-resolver.ts | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/plugin/transform/gemini.ts b/src/plugin/transform/gemini.ts index 65e0766..3c2f359 100644 --- a/src/plugin/transform/gemini.ts +++ b/src/plugin/transform/gemini.ts @@ -284,8 +284,17 @@ export function normalizeGeminiTools(payload: RequestPayload): { `tool-${toolIndex}`; // Always update function.input_schema with transformed schema + // CRITICAL: This must happen BEFORE custom creation so function tools + // keep their schema even after custom is stripped (line 332). if (newTool.function && schema) { (newTool.function as Record).input_schema = schema; + } else if (newTool.function && !schema) { + // Ensure function always has a schema even if source had none + (newTool.function as Record).input_schema = { + type: "OBJECT", + properties: {}, + }; + toolDebugMissing += 1; } // Always update custom.input_schema with transformed schema @@ -293,7 +302,7 @@ export function normalizeGeminiTools(payload: RequestPayload): { (newTool.custom as Record).input_schema = schema; } - // Create custom from function if missing + // Create custom from function if missing (temporary, stripped later) if (!newTool.custom && newTool.function) { const fn = newTool.function as Record; newTool.custom = { diff --git a/src/plugin/transform/model-resolver.ts b/src/plugin/transform/model-resolver.ts index b6a5451..598448b 100644 --- a/src/plugin/transform/model-resolver.ts +++ b/src/plugin/transform/model-resolver.ts @@ -48,6 +48,12 @@ export const MODEL_ALIASES: Record = { "gemini-3-flash-medium": "gemini-3-flash", "gemini-3-flash-high": "gemini-3-flash", + // Marketing aliases - map to real API model names + "gemini-omni-flash-preview": "gemini-3-flash", + "gemini-omni-flash": "gemini-3-flash", + "gemini-omni-pro-preview": "gemini-3-pro", + "gemini-omni-pro": "gemini-3-pro", + // Gemini 3.5 Flash - upstream uses tiered names (no bare model exists). // Each tier maps to a distinct upstream model ID (probed 200 OK). "gemini-3.5-flash": "gemini-3.5-flash-low", // default → Medium tier