Problem
When running gemini -p "..." --output-format stream-json with a thinking-capable model (e.g. Gemini 2.5 Pro), all Thought events emitted by the model are silently dropped. Developers building integrations on top of the non-interactive CLI have no way to observe the model's reasoning process.
The interactive UI already handles thinking events (useGeminiStream.ts), but the non-interactive stream-json path had no corresponding support.
Proposed Solution
- Add a
THINKING = 'thinking' event type to JsonStreamEventType in packages/core/src/output/types.ts
- Add a
ThinkingEvent interface (content: string, subject?: string) to the stream event type union
- Handle
GeminiEventType.Thought in the non-interactive response loop (nonInteractiveCli.ts) to emit structured thinking events when using --output-format stream-json
Example output (stream-json)
{"type":"thinking","timestamp":"...","content":"**Analysis** Let me think through this step by step...","subject":"Analysis"}
Impact
No breaking changes. The thinking event is additive — consumers that don't handle it can ignore it. Consumers that want model reasoning now have a structured way to access it.
Problem
When running
gemini -p "..." --output-format stream-jsonwith a thinking-capable model (e.g. Gemini 2.5 Pro), allThoughtevents emitted by the model are silently dropped. Developers building integrations on top of the non-interactive CLI have no way to observe the model's reasoning process.The interactive UI already handles thinking events (
useGeminiStream.ts), but the non-interactive stream-json path had no corresponding support.Proposed Solution
THINKING = 'thinking'event type toJsonStreamEventTypeinpackages/core/src/output/types.tsThinkingEventinterface (content: string,subject?: string) to the stream event type unionGeminiEventType.Thoughtin the non-interactive response loop (nonInteractiveCli.ts) to emit structuredthinkingevents when using--output-format stream-jsonExample output (stream-json)
{"type":"thinking","timestamp":"...","content":"**Analysis** Let me think through this step by step...","subject":"Analysis"}Impact
No breaking changes. The
thinkingevent is additive — consumers that don't handle it can ignore it. Consumers that want model reasoning now have a structured way to access it.