mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 02:24:09 -07:00
feat(core): Unified Context Management and Tool Distillation. (#24157)
This commit is contained in:
@@ -293,6 +293,7 @@ describe('WebFetchTool', () => {
|
||||
})),
|
||||
},
|
||||
isInteractive: () => false,
|
||||
isAutoDistillationEnabled: vi.fn().mockReturnValue(false),
|
||||
} as unknown as Config;
|
||||
});
|
||||
|
||||
@@ -1118,5 +1119,40 @@ describe('WebFetchTool', () => {
|
||||
);
|
||||
expect(result.error?.type).toBe(ToolErrorType.WEB_FETCH_PROCESSING_ERROR);
|
||||
});
|
||||
|
||||
it('should bypass truncation if isAutoDistillationEnabled is true', async () => {
|
||||
vi.spyOn(mockConfig, 'isAutoDistillationEnabled').mockReturnValue(true);
|
||||
const largeContent = 'a'.repeat(300000); // Larger than MAX_CONTENT_LENGTH (250000)
|
||||
mockFetch('https://example.com/large-text', {
|
||||
status: 200,
|
||||
headers: new Headers({ 'content-type': 'text/plain' }),
|
||||
text: () => Promise.resolve(largeContent),
|
||||
});
|
||||
|
||||
const tool = new WebFetchTool(mockConfig, bus);
|
||||
const invocation = tool.build({ url: 'https://example.com/large-text' });
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
|
||||
expect((result.llmContent as string).length).toBe(300000); // No truncation
|
||||
});
|
||||
|
||||
it('should truncate if isAutoDistillationEnabled is false', async () => {
|
||||
vi.spyOn(mockConfig, 'isAutoDistillationEnabled').mockReturnValue(false);
|
||||
const largeContent = 'a'.repeat(300000); // Larger than MAX_CONTENT_LENGTH (250000)
|
||||
mockFetch('https://example.com/large-text2', {
|
||||
status: 200,
|
||||
headers: new Headers({ 'content-type': 'text/plain' }),
|
||||
text: () => Promise.resolve(largeContent),
|
||||
});
|
||||
|
||||
const tool = new WebFetchTool(mockConfig, bus);
|
||||
const invocation = tool.build({ url: 'https://example.com/large-text2' });
|
||||
const result = await invocation.execute(new AbortController().signal);
|
||||
|
||||
expect((result.llmContent as string).length).toBeLessThan(300000);
|
||||
expect(result.llmContent).toContain(
|
||||
'[Content truncated due to size limit]',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user