From 7966b336a98ad2c63ffb7184d1b4e9b955495301 Mon Sep 17 00:00:00 2001 From: jacob314 Date: Mon, 6 Apr 2026 12:52:55 -0700 Subject: [PATCH] Fix so we always show a shell command description or the command. --- packages/core/src/tools/shell.test.ts | 26 ++++++++++++++++++++++++++ packages/core/src/tools/shell.ts | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/core/src/tools/shell.test.ts b/packages/core/src/tools/shell.test.ts index 245b7f0eee3..9551fd96382 100644 --- a/packages/core/src/tools/shell.test.ts +++ b/packages/core/src/tools/shell.test.ts @@ -803,6 +803,32 @@ describe('ShellTool', () => { }); }); + describe('invocation getDescription', () => { + it('should return the description if it is present and not empty whitespace', () => { + const invocation = shellTool.build({ + command: 'echo hello', + description: 'prints hello', + }); + expect(invocation.getDescription()).toBe('prints hello'); + }); + + it('should return the raw command if description is an empty string', () => { + const invocation = shellTool.build({ + command: 'echo hello', + description: '', + }); + expect(invocation.getDescription()).toBe('echo hello'); + }); + + it('should return the raw command if description is just whitespace', () => { + const invocation = shellTool.build({ + command: 'echo hello', + description: ' ', + }); + expect(invocation.getDescription()).toBe('echo hello'); + }); + }); + describe('llmContent output format', () => { const mockAbortSignal = new AbortController().signal; diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts index 7ca475808aa..3ea29474c65 100644 --- a/packages/core/src/tools/shell.ts +++ b/packages/core/src/tools/shell.ts @@ -136,7 +136,9 @@ export class ShellToolInvocation extends BaseToolInvocation< } getDescription(): string { - return this.params.description || ''; + return this.params.description?.trim() + ? this.params.description + : this.params.command; } private simplifyPaths(paths: Set): string[] {