mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-16 00:51:25 -07:00
Make compression algo slightly more aggressive (#10024)
This commit is contained in:
committed by
GitHub
parent
db51e3f4cd
commit
93694c6a65
@@ -131,7 +131,7 @@ async function fromAsync<T>(promise: AsyncGenerator<T>): Promise<readonly T[]> {
|
||||
return results;
|
||||
}
|
||||
|
||||
describe('findIndexAfterFraction', () => {
|
||||
describe('findCompressSplitPoint', () => {
|
||||
it('should throw an error for non-positive numbers', () => {
|
||||
expect(() => findCompressSplitPoint([], 0)).toThrow(
|
||||
'Fraction must be between 0 and 1',
|
||||
@@ -156,7 +156,7 @@ describe('findIndexAfterFraction', () => {
|
||||
{ role: 'model', parts: [{ text: 'This is the fourth message.' }] }, // JSON length: 68 (80%)
|
||||
{ role: 'user', parts: [{ text: 'This is the fifth message.' }] }, // JSON length: 65 (100%)
|
||||
];
|
||||
expect(findCompressSplitPoint(history, 0.5)).toBe(2);
|
||||
expect(findCompressSplitPoint(history, 0.5)).toBe(4);
|
||||
});
|
||||
|
||||
it('should handle a fraction of last index', () => {
|
||||
|
||||
@@ -83,7 +83,6 @@ export function findCompressSplitPoint(
|
||||
let lastSplitPoint = 0; // 0 is always valid (compress nothing)
|
||||
let cumulativeCharCount = 0;
|
||||
for (let i = 0; i < contents.length; i++) {
|
||||
cumulativeCharCount += charCounts[i];
|
||||
const content = contents[i];
|
||||
if (
|
||||
content.role === 'user' &&
|
||||
@@ -94,6 +93,7 @@ export function findCompressSplitPoint(
|
||||
}
|
||||
lastSplitPoint = i;
|
||||
}
|
||||
cumulativeCharCount += charCounts[i];
|
||||
}
|
||||
|
||||
// We found no split points after targetCharCount.
|
||||
|
||||
Reference in New Issue
Block a user