From 0643481cbd3d9516a5c44a33326964da62fc5ba8 Mon Sep 17 00:00:00 2001 From: Aishanee Shah Date: Tue, 17 Feb 2026 23:07:43 +0000 Subject: [PATCH] feat(shell): always include exit_code in subprocess_result XML --- packages/core/src/tools/shell.test.ts | 5 +++-- packages/core/src/tools/shell.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/tools/shell.test.ts b/packages/core/src/tools/shell.test.ts index ad93ad873b..5f1bf1f534 100644 --- a/packages/core/src/tools/shell.test.ts +++ b/packages/core/src/tools/shell.test.ts @@ -687,13 +687,13 @@ describe('ShellTool', () => { expect(result.llmContent).not.toContain('Directory:'); }); - it('should not include Exit Code when command succeeds (exit code 0)', async () => { + it('should include Exit Code when command succeeds (exit code 0)', async () => { const invocation = shellTool.build({ command: 'echo hello' }); const promise = invocation.execute(mockAbortSignal); resolveShellExecution({ output: 'hello', exitCode: 0 }); const result = await promise; - expect(result.llmContent).not.toContain(''); + expect(result.llmContent).toContain('0'); }); it('should include Exit Code when command fails (non-zero exit code)', async () => { @@ -776,6 +776,7 @@ describe('ShellTool', () => { // Should only contain subprocess_result and output expect(result.llmContent).toContain(''); expect(result.llmContent).toContain('hello'); + expect(result.llmContent).toContain('0'); }); }); diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts index 15ef55be8d..185c176593 100644 --- a/packages/core/src/tools/shell.ts +++ b/packages/core/src/tools/shell.ts @@ -365,7 +365,7 @@ export class ShellToolInvocation extends BaseToolInvocation< parts.push(`${finalError}`); } - if (result.exitCode !== null && result.exitCode !== 0) { + if (result.exitCode !== null) { parts.push(`${result.exitCode}`); }