From 66b61a13b4d91780a60eeb77f8c21f2563eed07f Mon Sep 17 00:00:00 2001 From: gemini-cli-robot Date: Thu, 30 Oct 2025 16:35:15 -0700 Subject: [PATCH] fix(patch): cherry-pick 68afb72 to release/v0.12.0-preview.3-pr-12306 to patch version v0.12.0-preview.3 and create version 0.12.0-preview.4 (#12327) Co-authored-by: Tommaso Sciortino --- packages/core/src/services/chatCompressionService.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/core/src/services/chatCompressionService.ts b/packages/core/src/services/chatCompressionService.ts index cdfb093e5d..0c94130398 100644 --- a/packages/core/src/services/chatCompressionService.ts +++ b/packages/core/src/services/chatCompressionService.ts @@ -17,10 +17,10 @@ import { makeChatCompressionEvent } from '../telemetry/types.js'; import { getInitialChatHistory } from '../utils/environmentContext.js'; /** - * Threshold for compression token count as a fraction of the model's token limit. - * If the chat history exceeds this threshold, it will be compressed. + * Default threshold for compression token count as a fraction of the model's + * token limit. If the chat history exceeds this threshold, it will be compressed. */ -export const COMPRESSION_TOKEN_THRESHOLD = 0.7; +export const DEFAULT_COMPRESSION_TOKEN_THRESHOLD = 0.2; /** * The fraction of the latest chat history to keep. A value of 0.3 @@ -104,13 +104,11 @@ export class ChatCompressionService { const originalTokenCount = uiTelemetryService.getLastPromptTokenCount(); - const contextPercentageThreshold = - config.getChatCompression()?.contextPercentageThreshold; - // Don't compress if not forced and we are under the limit. if (!force) { const threshold = - contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD; + config.getChatCompression()?.contextPercentageThreshold ?? + DEFAULT_COMPRESSION_TOKEN_THRESHOLD; if (originalTokenCount < threshold * tokenLimit(model)) { return { newHistory: null,