Skip to content

feat: add reasoning event support to Gemini CLI bridge#1236

Open
ambient-code[bot] wants to merge 1 commit intomainfrom
feat/gemini-reasoning-events
Open

feat: add reasoning event support to Gemini CLI bridge#1236
ambient-code[bot] wants to merge 1 commit intomainfrom
feat/gemini-reasoning-events

Conversation

@ambient-code
Copy link
Copy Markdown
Contributor

@ambient-code ambient-code bot commented Apr 7, 2026

Summary

  • Adds ThinkingEvent type to ag_ui_gemini_cli/types.py to parse thinking events from the Gemini CLI NDJSON stream
  • Wires up REASONING_START, REASONING_MESSAGE_START/CONTENT/END, and REASONING_END AG-UI event emission in the Gemini CLI adapter, reusing the existing reasoning event models from ag_ui_claude_sdk.reasoning_events
  • Properly closes open reasoning blocks on transitions to text messages, tool calls, errors, and run completion
  • Adds 5 new tests (2 parse tests + 3 adapter integration tests)

Context

Investigation of the Gemini CLI source confirms that:

  • The CLI internally has GeminiEventType.Thought events with ThoughtSummary data (subject + description)
  • These are used for the interactive terminal UI (see ThinkingMessage.tsx)
  • However, the stream-json output format does not currently emit thinking events — the nonInteractiveCli.ts event loop silently drops them
  • The JsonStreamEventType enum only has 6 types: init, message, tool_use, tool_result, error, result

This PR prepares the adapter so it will automatically handle thinking events when the Gemini CLI adds thinking to its streaming JSON output. Until then, unknown event types are harmlessly ignored by parse_event().

Test plan

  • All 18 Gemini CLI adapter tests pass (13 existing + 5 new)
  • No regressions in the broader runner test suite (15 pre-existing failures unrelated to this change)
  • Verify reasoning events render correctly in the frontend once the Gemini CLI adds thinking support upstream

Closes #1127

🤖 Generated with Claude Code

Add support for emitting REASONING_MESSAGE_START/CONTENT/END AG-UI events
in the Gemini CLI adapter by parsing 'thinking' events from the NDJSON
stream. This reuses the existing reasoning event models from the Claude
SDK adapter.

The Gemini CLI internally tracks thinking via GeminiEventType.Thought but
does not yet surface it in the stream-json output format. This change
prepares the adapter to handle thinking events as soon as upstream support
is added, while remaining a no-op for current CLI versions.

Closes #1127

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ambient-code ambient-code bot added ambient-code:managed PR managed by AI automation ambient-code:needs-human AI circuit breaker fired, needs human attention and removed ambient-code:managed PR managed by AI automation labels Apr 7, 2026
@ambient-code
Copy link
Copy Markdown
Contributor Author

ambient-code bot commented Apr 7, 2026

Circuit breaker triggered (retry_count=3)

This PR has been retried 3 times without receiving human review. All CI checks pass and there are no merge conflicts or review comments to address.

Current state:

  • CI: All checks green
  • Conflicts: None
  • Review comments: None

The PR is ready for human review. Labeling as ambient-code:needs-human.

@github-actions github-actions bot added this to the Review Queue milestone Apr 7, 2026
@Gkrumbach07
Copy link
Copy Markdown
Contributor

@ambient-code This is WRONG. you are using claude types in the gemini CLI. You MUST only use Gemini types in the gemini cli and vise versa for claude. research the gemini cli more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ambient-code:needs-human AI circuit breaker fired, needs human attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add reasoning event support to Gemini CLI bridge

1 participant