Skip to content

feat(cli): expose model thinking events in --output-format stream-json #22083

@KobiAms

Description

@KobiAms

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/non-interactiveIssues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automationpriority/p2Important but can be addressed in a future release.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions