* fix(agents): add "google" provider to isReasoningTagProvider to prevent reasoning leak The gemini-api-key auth flow creates a profile with provider "google" (e.g. google/gemini-3-pro-preview), but isReasoningTagProvider only matched "google-gemini-cli" (OAuth) and "google-generative-ai". As a result: - reasoningTagHint was false → system prompt omitted <think>/<final> formatting instructions - enforceFinalTag was false → <final> tag filtering was skipped Raw <think> reasoning output was delivered to the end user. Fix: add the bare "google" provider string to the match list and cover it with two new test cases (exact match + case-insensitive). Fixes #26551 * fix(agents): add forward-compat fallback for google-gemini-cli gemini-3.1-pro/flash-preview gemini-3.1-pro-preview and gemini-3.1-flash-preview are not yet present in pi-ai's built-in google-gemini-cli model catalog (only gemini-3-pro-preview and gemini-3-flash-preview are registered). When users configure these models they get "Unknown model" errors even though Gemini CLI OAuth supports them. The codebase already has isGemini31Model() in extra-params.ts, which proves intent to support these models. Add a resolveGoogleGeminiCli31ForwardCompatModel entry to resolveForwardCompatModel following the same clone-template pattern used for zai/glm-5 and anthropic 4.6 models. - gemini-3.1-pro-* clones gemini-3-pro-preview (with reasoning: true) - gemini-3.1-flash-* clones gemini-3-flash-preview (with reasoning: true) Also add test helpers and three test cases to model.forward-compat.test.ts. Fixes #26524 * Changelog: credit Google Gemini provider fallback fixes --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
90 lines
3.0 KiB
TypeScript
90 lines
3.0 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("../pi-model-discovery.js", () => ({
|
|
discoverAuthStorage: vi.fn(() => ({ mocked: true })),
|
|
discoverModels: vi.fn(() => ({ find: vi.fn(() => null) })),
|
|
}));
|
|
|
|
import { buildInlineProviderModels, resolveModel } from "./model.js";
|
|
import {
|
|
buildOpenAICodexForwardCompatExpectation,
|
|
GOOGLE_GEMINI_CLI_FLASH_TEMPLATE_MODEL,
|
|
GOOGLE_GEMINI_CLI_PRO_TEMPLATE_MODEL,
|
|
makeModel,
|
|
mockGoogleGeminiCliFlashTemplateModel,
|
|
mockGoogleGeminiCliProTemplateModel,
|
|
mockOpenAICodexTemplateModel,
|
|
resetMockDiscoverModels,
|
|
} from "./model.test-harness.js";
|
|
|
|
beforeEach(() => {
|
|
resetMockDiscoverModels();
|
|
});
|
|
|
|
describe("pi embedded model e2e smoke", () => {
|
|
it("attaches provider ids and provider-level baseUrl for inline models", () => {
|
|
const providers = {
|
|
custom: {
|
|
baseUrl: "http://localhost:8000",
|
|
models: [makeModel("custom-model")],
|
|
},
|
|
};
|
|
|
|
const result = buildInlineProviderModels(providers);
|
|
expect(result).toEqual([
|
|
{
|
|
...makeModel("custom-model"),
|
|
provider: "custom",
|
|
baseUrl: "http://localhost:8000",
|
|
api: undefined,
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("builds an openai-codex forward-compat fallback for gpt-5.3-codex", () => {
|
|
mockOpenAICodexTemplateModel();
|
|
|
|
const result = resolveModel("openai-codex", "gpt-5.3-codex", "/tmp/agent");
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.model).toMatchObject(buildOpenAICodexForwardCompatExpectation("gpt-5.3-codex"));
|
|
});
|
|
|
|
it("keeps unknown-model errors for non-forward-compat IDs", () => {
|
|
const result = resolveModel("openai-codex", "gpt-4.1-mini", "/tmp/agent");
|
|
expect(result.model).toBeUndefined();
|
|
expect(result.error).toBe("Unknown model: openai-codex/gpt-4.1-mini");
|
|
});
|
|
|
|
it("builds a google-gemini-cli forward-compat fallback for gemini-3.1-pro-preview", () => {
|
|
mockGoogleGeminiCliProTemplateModel();
|
|
|
|
const result = resolveModel("google-gemini-cli", "gemini-3.1-pro-preview", "/tmp/agent");
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.model).toMatchObject({
|
|
...GOOGLE_GEMINI_CLI_PRO_TEMPLATE_MODEL,
|
|
id: "gemini-3.1-pro-preview",
|
|
name: "gemini-3.1-pro-preview",
|
|
reasoning: true,
|
|
});
|
|
});
|
|
|
|
it("builds a google-gemini-cli forward-compat fallback for gemini-3.1-flash-preview", () => {
|
|
mockGoogleGeminiCliFlashTemplateModel();
|
|
|
|
const result = resolveModel("google-gemini-cli", "gemini-3.1-flash-preview", "/tmp/agent");
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.model).toMatchObject({
|
|
...GOOGLE_GEMINI_CLI_FLASH_TEMPLATE_MODEL,
|
|
id: "gemini-3.1-flash-preview",
|
|
name: "gemini-3.1-flash-preview",
|
|
reasoning: true,
|
|
});
|
|
});
|
|
|
|
it("keeps unknown-model errors for unrecognized google-gemini-cli model IDs", () => {
|
|
const result = resolveModel("google-gemini-cli", "gemini-4-unknown", "/tmp/agent");
|
|
expect(result.model).toBeUndefined();
|
|
expect(result.error).toBe("Unknown model: google-gemini-cli/gemini-4-unknown");
|
|
});
|
|
});
|