mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-12 07:01:09 -07:00
Change default compression threshold (#12306)
This commit is contained in:
committed by
GitHub
parent
b382ae6803
commit
68afb7200e
@@ -17,10 +17,10 @@ import { makeChatCompressionEvent } from '../telemetry/types.js';
|
|||||||
import { getInitialChatHistory } from '../utils/environmentContext.js';
|
import { getInitialChatHistory } from '../utils/environmentContext.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Threshold for compression token count as a fraction of the model's token limit.
|
* Default threshold for compression token count as a fraction of the model's
|
||||||
* If the chat history exceeds this threshold, it will be compressed.
|
* 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
|
* 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 originalTokenCount = uiTelemetryService.getLastPromptTokenCount();
|
||||||
|
|
||||||
const contextPercentageThreshold =
|
|
||||||
config.getChatCompression()?.contextPercentageThreshold;
|
|
||||||
|
|
||||||
// Don't compress if not forced and we are under the limit.
|
// Don't compress if not forced and we are under the limit.
|
||||||
if (!force) {
|
if (!force) {
|
||||||
const threshold =
|
const threshold =
|
||||||
contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD;
|
config.getChatCompression()?.contextPercentageThreshold ??
|
||||||
|
DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
|
||||||
if (originalTokenCount < threshold * tokenLimit(model)) {
|
if (originalTokenCount < threshold * tokenLimit(model)) {
|
||||||
return {
|
return {
|
||||||
newHistory: null,
|
newHistory: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user