* 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>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* Utility functions for provider-specific logic and capabilities.
|
|
*/
|
|
|
|
/**
|
|
* Returns true if the provider requires reasoning to be wrapped in tags
|
|
* (e.g. <think> and <final>) in the text stream, rather than using native
|
|
* API fields for reasoning/thinking.
|
|
*/
|
|
export function isReasoningTagProvider(provider: string | undefined | null): boolean {
|
|
if (!provider) {
|
|
return false;
|
|
}
|
|
const normalized = provider.trim().toLowerCase();
|
|
|
|
// Check for exact matches or known prefixes/substrings for reasoning providers.
|
|
// Note: Ollama is intentionally excluded - its OpenAI-compatible endpoint
|
|
// handles reasoning natively via the `reasoning` field in streaming chunks,
|
|
// so tag-based enforcement is unnecessary and causes all output to be
|
|
// discarded as "(no output)" (#2279).
|
|
if (
|
|
normalized === "google" ||
|
|
normalized === "google-gemini-cli" ||
|
|
normalized === "google-generative-ai"
|
|
) {
|
|
return true;
|
|
}
|
|
|
|
// Handle Minimax (M2.1 is chatty/reasoning-like)
|
|
if (normalized.includes("minimax")) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|