mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
feat(shell): always include exit_code in subprocess_result XML
This commit is contained in:
@@ -687,13 +687,13 @@ describe('ShellTool', () => {
|
|||||||
expect(result.llmContent).not.toContain('Directory:');
|
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 invocation = shellTool.build({ command: 'echo hello' });
|
||||||
const promise = invocation.execute(mockAbortSignal);
|
const promise = invocation.execute(mockAbortSignal);
|
||||||
resolveShellExecution({ output: 'hello', exitCode: 0 });
|
resolveShellExecution({ output: 'hello', exitCode: 0 });
|
||||||
|
|
||||||
const result = await promise;
|
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 () => {
|
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
|
// Should only contain subprocess_result and output
|
||||||
expect(result.llmContent).toContain('<subprocess_result>');
|
expect(result.llmContent).toContain('<subprocess_result>');
|
||||||
expect(result.llmContent).toContain('<output>hello</output>');
|
expect(result.llmContent).toContain('<output>hello</output>');
|
||||||
|
expect(result.llmContent).toContain('<exit_code>0</exit_code>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ export class ShellToolInvocation extends BaseToolInvocation<
|
|||||||
parts.push(`<error>${finalError}</error>`);
|
parts.push(`<error>${finalError}</error>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.exitCode !== null && result.exitCode !== 0) {
|
if (result.exitCode !== null) {
|
||||||
parts.push(`<exit_code>${result.exitCode}</exit_code>`);
|
parts.push(`<exit_code>${result.exitCode}</exit_code>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user