Enable tool summarization only when explicitly set in settings.json (#4140)

Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
anj-s
2025-07-15 10:22:31 -07:00
committed by GitHub
parent 7effdad3e2
commit d3ee9de3c3
8 changed files with 153 additions and 20 deletions

View File

@@ -410,6 +410,9 @@ describe('ShellTool Bug Reproduction', () => {
getDebugMode: () => false,
getGeminiClient: () => ({}) as GeminiClient,
getTargetDir: () => '.',
getSummarizeToolOutputConfig: () => ({
[shellTool.name]: {},
}),
} as unknown as Config;
shellTool = new ShellTool(config);
});
@@ -429,4 +432,86 @@ describe('ShellTool Bug Reproduction', () => {
expect(result.llmContent).toBe('summarized output');
expect(summarizeSpy).toHaveBeenCalled();
});
it('should not call summarizer if disabled in config', async () => {
config = {
getCoreTools: () => undefined,
getExcludeTools: () => undefined,
getDebugMode: () => false,
getGeminiClient: () => ({}) as GeminiClient,
getTargetDir: () => '.',
getSummarizeToolOutputConfig: () => ({}),
} as unknown as Config;
shellTool = new ShellTool(config);
const summarizeSpy = vi
.spyOn(summarizer, 'summarizeToolOutput')
.mockResolvedValue('summarized output');
const abortSignal = new AbortController().signal;
const result = await shellTool.execute(
{ command: 'echo "hello"' },
abortSignal,
);
expect(result.returnDisplay).toBe('hello\n');
expect(result.llmContent).not.toBe('summarized output');
expect(summarizeSpy).not.toHaveBeenCalled();
});
it('should pass token budget to summarizer', async () => {
config = {
getCoreTools: () => undefined,
getExcludeTools: () => undefined,
getDebugMode: () => false,
getGeminiClient: () => ({}) as GeminiClient,
getTargetDir: () => '.',
getSummarizeToolOutputConfig: () => ({
[shellTool.name]: { tokenBudget: 1000 },
}),
} as unknown as Config;
shellTool = new ShellTool(config);
const summarizeSpy = vi
.spyOn(summarizer, 'summarizeToolOutput')
.mockResolvedValue('summarized output');
const abortSignal = new AbortController().signal;
await shellTool.execute({ command: 'echo "hello"' }, abortSignal);
expect(summarizeSpy).toHaveBeenCalledWith(
expect.any(String),
expect.any(Object),
expect.any(Object),
1000,
);
});
it('should use default token budget if not specified', async () => {
config = {
getCoreTools: () => undefined,
getExcludeTools: () => undefined,
getDebugMode: () => false,
getGeminiClient: () => ({}) as GeminiClient,
getTargetDir: () => '.',
getSummarizeToolOutputConfig: () => ({
[shellTool.name]: {},
}),
} as unknown as Config;
shellTool = new ShellTool(config);
const summarizeSpy = vi
.spyOn(summarizer, 'summarizeToolOutput')
.mockResolvedValue('summarized output');
const abortSignal = new AbortController().signal;
await shellTool.execute({ command: 'echo "hello"' }, abortSignal);
expect(summarizeSpy).toHaveBeenCalledWith(
expect.any(String),
expect.any(Object),
expect.any(Object),
undefined,
);
});
});