From 565714a015e673514fc88cb48f4a9d8c8411fc00 Mon Sep 17 00:00:00 2001 From: "@taltas" <6816042+taltas@users.noreply.github.com> Date: Fri, 16 Oct 2026 22:39:00 +0000 Subject: [PATCH] feat(providers): clamp Gemini 4 Argon limits on Vercel AI Gateway to Google's values --- .../__tests__/vercel-ai-gateway.spec.ts | 27 +++++++++++++++++++ .../providers/fetchers/vercel-ai-gateway.ts | 13 +++++++++ 2 files changed, 40 insertions(+) diff --git a/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts b/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts index 1331ed4049..85ce9cf065 100644 --- a/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts +++ b/src/api/providers/fetchers/__tests__/vercel-ai-gateway.spec.ts @@ -196,6 +196,33 @@ describe("Vercel AI Gateway Fetchers", () => { }, } + it("applies Google's authoritative limits and thinking levels to google/gemini-4-argon", () => { + // The gateway catalog reports context_window and max_tokens of 1,000,000; + // Google's documented limits are a shared 1,048,576-token window and a + // 65,536-token single-request output cap. + const result = parseVercelAiGatewayModel({ + id: "google/gemini-4-argon", + model: { + ...baseModel, + id: "google/gemini-4-argon", + name: "Gemini 4 Argon", + owned_by: "google", + context_window: 1_000_000, + max_tokens: 1_000_000, + tags: ["reasoning", "vision", "tool-use", "implicit-caching"], + }, + }) + + expect(result).toMatchObject({ + contextWindow: 1_048_576, + maxTokens: 65_536, + supportsImages: true, + supportsReasoningEffort: ["low", "medium", "high"], + reasoningEffort: "medium", + supportsTemperature: false, + }) + }) + it.each(["openai/gpt-6-astra", "openai/gpt-6-astra-fast"])( "applies required Astra request constraints to %s", (id) => { diff --git a/src/api/providers/fetchers/vercel-ai-gateway.ts b/src/api/providers/fetchers/vercel-ai-gateway.ts index e9271f07af..04d785124a 100644 --- a/src/api/providers/fetchers/vercel-ai-gateway.ts +++ b/src/api/providers/fetchers/vercel-ai-gateway.ts @@ -125,6 +125,19 @@ export const parseVercelAiGatewayModel = ({ id, model }: { id: string; model: Ve description: model.description ?? model.name, } + if (id === "google/gemini-4-argon") { + // The gateway catalog reports context_window and max_tokens of 1,000,000, + // but Google's authoritative limits are a shared 1,048,576-token window + // (input + thinking + output) and a 65,536-token single-request output cap + // (longer decodes use continuation tokens). + modelInfo.contextWindow = 1_048_576 + modelInfo.maxTokens = 65_536 + modelInfo.supportsReasoningEffort = ["low", "medium", "high"] + modelInfo.reasoningEffort = "medium" + // The Google backend ignores temperature/top_p/top_k on this model. + modelInfo.supportsTemperature = false + } + if (id === "openai/gpt-6-astra" || id === "openai/gpt-6-astra-fast") { modelInfo.supportsReasoningEffort = ["low", "medium", "high", "xhigh", "max"] modelInfo.requiredReasoningEffort = true