mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
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:
@@ -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,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user