diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx index 7bd3f3955b..892ee9862a 100644 --- a/packages/cli/src/gemini.tsx +++ b/packages/cli/src/gemini.tsx @@ -830,7 +830,7 @@ export function initializeOutputListenersAndFlush(config?: Config) { } const outputFormat = config?.getOutputFormat(); - const forceToStderr = outputFormat === 'json' || config === undefined; + const forceToStderr = outputFormat === 'json'; coreEvents.drainBacklogs( (event: K, args: CoreEvents[K]) => { diff --git a/packages/cli/src/output-redirection.test.ts b/packages/cli/src/output-redirection.test.ts index 2dc935b330..8baa1127f5 100644 --- a/packages/cli/src/output-redirection.test.ts +++ b/packages/cli/src/output-redirection.test.ts @@ -69,16 +69,16 @@ describe('Output Redirection', () => { expect(writeToStderr).not.toHaveBeenCalled(); }); - it('should force stdout to stderr when config is undefined (early failure)', () => { + it('should NOT force stdout to stderr when config is undefined (early init/version)', () => { // Simulate buffered output during early init coreEvents.emitOutput(false, 'early init message'); // Initialize with undefined config initializeOutputListenersAndFlush(undefined); - // Verify it was forced to stderr - expect(writeToStderr).toHaveBeenCalledWith('early init message', undefined); - expect(writeToStdout).not.toHaveBeenCalled(); + // Verify it went to stdout (default behavior) + expect(writeToStdout).toHaveBeenCalledWith('early init message', undefined); + expect(writeToStderr).not.toHaveBeenCalled(); }); it('should attach ConsoleLog and UserFeedback listeners even if Output already has one', () => {