fix(core): map PREVIEW_GEMINI_FLASH_MODEL to stable 3.1 lite and fix history coalescing

This commit is contained in:
Sehoon Shon
2026-04-01 00:26:27 -04:00
parent 428a4808db
commit d18586fec2
3 changed files with 35 additions and 28 deletions
+1 -1
View File
@@ -54,9 +54,9 @@ export const PREVIEW_GEMINI_MODEL = 'gemini-3-pro-preview';
export const PREVIEW_GEMINI_3_1_MODEL = 'gemini-3.1-pro-preview';
export const PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL =
'gemini-3.1-pro-preview-customtools';
export const PREVIEW_GEMINI_FLASH_MODEL = 'gemini-3-flash-preview';
export const PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL =
'gemini-3.1-flash-lite-preview';
export const PREVIEW_GEMINI_FLASH_MODEL = PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL;
export const DEFAULT_GEMINI_MODEL = 'gemini-2.5-pro';
export const DEFAULT_GEMINI_FLASH_MODEL = 'gemini-2.5-flash';
export const DEFAULT_GEMINI_FLASH_LITE_MODEL = 'gemini-2.5-flash-lite';
+32 -25
View File
@@ -173,7 +173,11 @@ function extractCuratedHistory(comprehensiveHistory: Content[]): Content[] {
if (part === undefined || Object.keys(part).length === 0) {
return false;
}
if (!part.thought && part.text !== undefined && part.text.trim() === '') {
// Thought parts should always be kept if present
if (part.thought) {
return true;
}
if (part.text !== undefined && part.text.trim() === '') {
return false;
}
return true;
@@ -183,39 +187,42 @@ function extractCuratedHistory(comprehensiveHistory: Content[]): Content[] {
continue;
}
const lastEntry = curatedHistory[curatedHistory.length - 1];
let lastEntry = curatedHistory[curatedHistory.length - 1];
if (lastEntry && lastEntry.role === role) {
const lastEntryParts = lastEntry.parts || [];
// Merge into last entry
for (const part of validParts) {
if (
lastEntryParts.length > 0 &&
lastEntryParts[lastEntryParts.length - 1].text !== undefined &&
part.text !== undefined
) {
// Coalesce text parts
const lastText = lastEntryParts[lastEntryParts.length - 1].text!;
const separator = lastText.endsWith('\n') ? '' : '\n';
lastEntryParts[lastEntryParts.length - 1] = {
...lastEntryParts[lastEntryParts.length - 1],
text: lastText + separator + part.text,
};
} else {
lastEntryParts.push({ ...part });
}
}
lastEntry.parts = lastEntryParts;
} else {
// Create new entry with deep-copied parts
curatedHistory.push({
// Create new entry
lastEntry = {
role,
parts: validParts.map((p) => ({ ...p })),
});
parts: [],
};
curatedHistory.push(lastEntry);
}
const lastEntryParts = lastEntry.parts || [];
for (const part of validParts) {
if (
lastEntryParts.length > 0 &&
lastEntryParts[lastEntryParts.length - 1].text !== undefined &&
part.text !== undefined
) {
// Coalesce text parts
const lastText = lastEntryParts[lastEntryParts.length - 1].text!;
const separator = lastText.endsWith('\n') ? '' : '\n';
lastEntryParts[lastEntryParts.length - 1] = {
...lastEntryParts[lastEntryParts.length - 1],
text: lastText + separator + part.text,
};
} else {
lastEntryParts.push({ ...part });
}
}
lastEntry.parts = lastEntryParts;
}
return curatedHistory;
}
export class InvalidStreamError extends Error {
readonly type:
| 'NO_FINISH_REASON'
+2 -2
View File
@@ -12,7 +12,7 @@ import { fileURLToPath } from 'node:url';
import { env } from 'node:process';
import { setTimeout as sleep } from 'node:timers/promises';
import {
PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL,
PREVIEW_GEMINI_FLASH_MODEL,
GEMINI_DIR,
} from '@google/gemini-cli-core';
export { GEMINI_DIR };
@@ -460,7 +460,7 @@ export class TestRig {
...(env['GEMINI_TEST_TYPE'] === 'integration'
? {
model: {
name: PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL,
name: PREVIEW_GEMINI_FLASH_MODEL,
},
}
: {}),