From f82d4300a4717f5ed035ef27c47f75559d0a8439 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sat, 28 Mar 2026 23:44:58 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore:=20Remove=20Deprecated=20G?= =?UTF-8?q?emini=202.0=20Models=20&=20Fix=20Mistral-Large-3=20Context=20Wi?= =?UTF-8?q?ndow=20(#12453)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: remove deprecated Gemini 2.0 models from default models list Remove gemini-2.0-flash-001 and gemini-2.0-flash-lite from the Google default models array, as they have been deprecated by Google. Closes #12444 * fix: add mistral-large-3 max context tokens (256k) Add mistral-large-3 with 255000 max context tokens to the mistralModels map. Without this entry, the model falls back to the generic mistral-large key (131k), causing context window errors when using tools with Azure AI Foundry deployments. Closes #12429 * test: add mistral-large-3 token resolution tests and fix key ordering Add test coverage for mistral-large-3 context token resolution, verifying exact match, suffixed variants, and longest-match precedence over the generic mistral-large key. Reorder the mistral-large-3 entry after mistral-large to follow the file's documented convention of listing newer models last for reverse-scan performance. --- api/utils/tokens.spec.js | 54 ++++++++++++++++++++++++++++ packages/api/src/utils/tokens.ts | 1 + packages/data-provider/src/config.ts | 3 -- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/api/utils/tokens.spec.js b/api/utils/tokens.spec.js index 6cecdb95c8..dfa6762ee5 100644 --- a/api/utils/tokens.spec.js +++ b/api/utils/tokens.spec.js @@ -1813,3 +1813,57 @@ describe('GLM Model Tests (Zhipu AI)', () => { }); }); }); + +describe('Mistral Model Tests', () => { + describe('getModelMaxTokens', () => { + test('should return correct tokens for mistral-large-3 (256k context)', () => { + expect(getModelMaxTokens('mistral-large-3', EModelEndpoint.custom)).toBe( + maxTokensMap[EModelEndpoint.custom]['mistral-large-3'], + ); + }); + + test('should match mistral-large-3 for suffixed variants', () => { + expect(getModelMaxTokens('mistral-large-3-instruct', EModelEndpoint.custom)).toBe( + maxTokensMap[EModelEndpoint.custom]['mistral-large-3'], + ); + }); + + test('should not match mistral-large-3 for generic mistral-large', () => { + expect(getModelMaxTokens('mistral-large', EModelEndpoint.custom)).toBe( + maxTokensMap[EModelEndpoint.custom]['mistral-large'], + ); + expect(getModelMaxTokens('mistral-large-latest', EModelEndpoint.custom)).toBe( + maxTokensMap[EModelEndpoint.custom]['mistral-large'], + ); + }); + }); + + describe('matchModelName', () => { + test('should match mistral-large-3 exactly', () => { + expect(matchModelName('mistral-large-3', EModelEndpoint.custom)).toBe('mistral-large-3'); + }); + + test('should match mistral-large-3 for prefixed/suffixed variants', () => { + expect(matchModelName('mistral/mistral-large-3', EModelEndpoint.custom)).toBe( + 'mistral-large-3', + ); + expect(matchModelName('mistral-large-3-instruct', EModelEndpoint.custom)).toBe( + 'mistral-large-3', + ); + }); + + test('should match generic mistral-large for non-3 variants', () => { + expect(matchModelName('mistral-large-latest', EModelEndpoint.custom)).toBe('mistral-large'); + }); + }); + + describe('findMatchingPattern', () => { + test('should prefer mistral-large-3 over mistral-large for mistral-large-3 variants', () => { + const result = findMatchingPattern( + 'mistral-large-3-instruct', + maxTokensMap[EModelEndpoint.custom], + ); + expect(result).toBe('mistral-large-3'); + }); + }); +}); diff --git a/packages/api/src/utils/tokens.ts b/packages/api/src/utils/tokens.ts index ae09da4f28..14215698a6 100644 --- a/packages/api/src/utils/tokens.ts +++ b/packages/api/src/utils/tokens.ts @@ -72,6 +72,7 @@ const mistralModels = { 'mistral-large-2402': 127500, 'mistral-large-2407': 127500, 'mistral-large': 131000, + 'mistral-large-3': 255000, 'mistral-saba': 32000, 'ministral-3b': 131000, 'ministral-8b': 131000, diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index e641d7b63a..bb89c56f82 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -1238,9 +1238,6 @@ export const defaultModels = { 'gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite', - // Gemini 2.0 Models - 'gemini-2.0-flash-001', - 'gemini-2.0-flash-lite', ], [EModelEndpoint.anthropic]: sharedAnthropicModels, [EModelEndpoint.openAI]: [