File tree Expand file tree Collapse file tree
packages/core/src/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,10 +17,10 @@ import { makeChatCompressionEvent } from '../telemetry/types.js';
1717import { 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 ,
You can’t perform that action at this time.
0 commit comments