Make compression threshold editable in the UI. (#12317)

This commit is contained in:
Tommaso Sciortino
2025-10-30 16:03:58 -07:00
committed by GitHub
parent 643f2c0958
commit 3332703fca
10 changed files with 41 additions and 109 deletions
@@ -70,7 +70,7 @@ describe('findCompressSplitPoint', () => {
expect(findCompressSplitPoint(history, 0.8)).toBe(4);
});
it('should return earlier splitpoint if no valid ones are after threshhold', () => {
it('should return earlier splitpoint if no valid ones are after threshold', () => {
const history: Content[] = [
{ role: 'user', parts: [{ text: 'This is the first message.' }] },
{ role: 'model', parts: [{ text: 'This is the second message.' }] },
@@ -115,7 +115,7 @@ describe('ChatCompressionService', () => {
getLastPromptTokenCount: vi.fn().mockReturnValue(500),
} as unknown as GeminiChat;
mockConfig = {
getChatCompression: vi.fn(),
getCompressionThreshold: vi.fn(),
getContentGenerator: vi.fn(),
} as unknown as Config;
@@ -106,8 +106,7 @@ export class ChatCompressionService {
// Don't compress if not forced and we are under the limit.
if (!force) {
const threshold =
config.getChatCompression()?.contextPercentageThreshold ??
DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
config.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
if (originalTokenCount < threshold * tokenLimit(model)) {
return {
newHistory: null,