summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/shell.test.ts
diff options
context:
space:
mode:
authoranj-s <[email protected]>2025-07-15 10:22:31 -0700
committerGitHub <[email protected]>2025-07-15 17:22:31 +0000
commitd3ee9de3c3b976ad45fe1a13eb49271d17a32e37 (patch)
tree10c9a2dbe37eb0602a716d92aea2290b61d9310b /packages/core/src/tools/shell.test.ts
parent7effdad3e27d4e6198249d3dba1bc52e89b76462 (diff)
Enable tool summarization only when explicitly set in settings.json (#4140)
Co-authored-by: matt korwel <[email protected]>
Diffstat (limited to 'packages/core/src/tools/shell.test.ts')
-rw-r--r--packages/core/src/tools/shell.test.ts85
1 files changed, 85 insertions, 0 deletions
diff --git a/packages/core/src/tools/shell.test.ts b/packages/core/src/tools/shell.test.ts
index a4d56e22..f358f972 100644
--- a/packages/core/src/tools/shell.test.ts
+++ b/packages/core/src/tools/shell.test.ts
@@ -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,
+ );
+ });
});