fix: correct gemini flash model id

This commit is contained in:
Peter Steinberger
2026-03-08 02:32:49 +00:00
parent 46008178d1
commit 100da9f45c
10 changed files with 26 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import { join } from "node:path";
import { describe, expect, it } from "vitest";
import {
normalizeAntigravityModelId,
normalizeGoogleModelId,
normalizeProviders,
type ProviderConfig,
} from "./models-config.providers.js";
@@ -47,6 +48,13 @@ describe("normalizeAntigravityModelId", () => {
});
});
describe("normalizeGoogleModelId", () => {
it("maps the deprecated 3.1 flash alias to the real preview model", () => {
expect(normalizeGoogleModelId("gemini-3.1-flash")).toBe("gemini-3-flash-preview");
expect(normalizeGoogleModelId("gemini-3.1-flash-preview")).toBe("gemini-3-flash-preview");
});
});
describe("google-antigravity provider normalization", () => {
it("normalizes bare gemini pro IDs only for google-antigravity providers", () => {
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));

View File

@@ -547,8 +547,11 @@ export function normalizeGoogleModelId(id: string): string {
if (id === "gemini-3.1-pro") {
return "gemini-3.1-pro-preview";
}
if (id === "gemini-3.1-flash") {
return "gemini-3.1-flash-preview";
// Preserve compatibility with earlier OpenClaw docs/config that pointed at a
// non-existent Gemini Flash preview ID. Google's current Flash text model is
// `gemini-3-flash-preview`.
if (id === "gemini-3.1-flash" || id === "gemini-3.1-flash-preview") {
return "gemini-3-flash-preview";
}
return id;
}

View File

@@ -29,7 +29,7 @@ const DEFAULT_MODEL_ALIASES: Readonly<Record<string, string>> = {
// Google Gemini (3.x are preview ids in the catalog)
gemini: "google/gemini-3.1-pro-preview",
"gemini-flash": "google/gemini-3.1-flash-preview",
"gemini-flash": "google/gemini-3-flash-preview",
};
const DEFAULT_MODEL_COST: ModelDefinitionConfig["cost"] = {

View File

@@ -68,7 +68,7 @@ describe("applyModelDefaults", () => {
defaults: {
models: {
"google/gemini-3.1-pro-preview": { alias: "" },
"google/gemini-3.1-flash-preview": {},
"google/gemini-3-flash-preview": {},
},
},
},
@@ -77,7 +77,7 @@ describe("applyModelDefaults", () => {
const next = applyModelDefaults(cfg);
expect(next.agents?.defaults?.models?.["google/gemini-3.1-pro-preview"]?.alias).toBe("");
expect(next.agents?.defaults?.models?.["google/gemini-3.1-flash-preview"]?.alias).toBe(
expect(next.agents?.defaults?.models?.["google/gemini-3-flash-preview"]?.alias).toBe(
"gemini-flash",
);
});