feat(shell): always include exit_code in subprocess_result XML

This commit is contained in:
Aishanee Shah
2026-02-17 23:07:43 +00:00
parent f8b3d14d26
commit 0643481cbd
2 changed files with 4 additions and 3 deletions

View File

@@ -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('<exit_code>');
expect(result.llmContent).toContain('<exit_code>0</exit_code>');
});
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('<subprocess_result>');
expect(result.llmContent).toContain('<output>hello</output>');
expect(result.llmContent).toContain('<exit_code>0</exit_code>');
});
});

View File

@@ -365,7 +365,7 @@ export class ShellToolInvocation extends BaseToolInvocation<
parts.push(`<error>${finalError}</error>`);
}
if (result.exitCode !== null && result.exitCode !== 0) {
if (result.exitCode !== null) {
parts.push(`<exit_code>${result.exitCode}</exit_code>`);
}