Skip to content

Commit 9424bd9

Browse files
scidominogemini-cli-robot
authored andcommitted
Change default compression threshold (#12306)
1 parent cd4bebb commit 9424bd9

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

packages/core/src/services/chatCompressionService.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import { makeChatCompressionEvent } from '../telemetry/types.js';
1717
import { getInitialChatHistory } from '../utils/environmentContext.js';
1818

1919
/**
20-
* Threshold for compression token count as a fraction of the model's token limit.
21-
* If the chat history exceeds this threshold, it will be compressed.
20+
* Default threshold for compression token count as a fraction of the model's
21+
* token limit. If the chat history exceeds this threshold, it will be compressed.
2222
*/
23-
export const COMPRESSION_TOKEN_THRESHOLD = 0.7;
23+
export const DEFAULT_COMPRESSION_TOKEN_THRESHOLD = 0.2;
2424

2525
/**
2626
* The fraction of the latest chat history to keep. A value of 0.3
@@ -104,13 +104,11 @@ export class ChatCompressionService {
104104

105105
const originalTokenCount = uiTelemetryService.getLastPromptTokenCount();
106106

107-
const contextPercentageThreshold =
108-
config.getChatCompression()?.contextPercentageThreshold;
109-
110107
// Don't compress if not forced and we are under the limit.
111108
if (!force) {
112109
const threshold =
113-
contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD;
110+
config.getChatCompression()?.contextPercentageThreshold ??
111+
DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
114112
if (originalTokenCount < threshold * tokenLimit(model)) {
115113
return {
116114
newHistory: null,

0 commit comments

Comments
 (0)