ductor icon indicating copy to clipboard operation
ductor copied to clipboard

Feature: Pass reasoning_effort config to Gemini CLI (thinking output leaks to Telegram)

Open downwind7clawd-ctrl opened this issue 7 months ago • 1 comments

Summary

When using Gemini CLI with models that support thinking (e.g., gemini-3-flash-preview), the thinking/reasoning output appears as literal text in the streamed response. Specifically, [Thought: true] markers and the reasoning content that follows are included in the message events and delivered directly to Telegram without filtering.

Current Behavior

  • Config reasoning_effort exists in config.json but is only passed to Codex, not Gemini CLI
  • Gemini CLI bundle has a thought_level session config option, but ductor doesn't configure it
  • gemini_events.py _parse_message_content_block() treats all text type blocks as regular content — no filtering of thinking markers
  • Result: [Thought: true] + reasoning text appears in Telegram messages

Expected Behavior

  • reasoning_effort config should be propagated to Gemini CLI (e.g., via GEMINI_THINKING_LEVEL env var or Gemini settings)
  • Alternatively, gemini_events.py should filter out thinking content from message events before delivering to Telegram

Environment

  • ductor: 0.15.0
  • Gemini CLI: installed via npm (@google/gemini-cli)
  • Model: gemini-3-flash-preview (thinking enabled by default)
  • Python: 3.12.3

Relevant Code

  • gemini_events.py _parse_message_content_block() — no thinking filter (Codex's stream_events.py has ThinkingEvent handling, but Gemini parser doesn't)
  • gemini_provider.py — reasoning_effort parameter not passed to Gemini CLI command
  • Gemini CLI bundle contains thought_level as a session config category

Suggested Fix

  1. Pass reasoning_effort to Gemini CLI (e.g., environment variable or CLI flag)
  2. Add thinking marker filtering in gemini_events.py as a fallback for models that embed thinking in text content

downwind7clawd-ctrl avatar Apr 21 '26 00:04 downwind7clawd-ctrl

Fixed in v0.16.0 (commit fd80c42).

Root cause traced to the Gemini CLI bundled chunk (chunk-EA775AOR.js::toPart2) wrapping thought: true parts as [Thought: ${value}]\n<text>. The fix lives at the NDJSON parser boundary (gemini_events.py::_split_thought_and_text) — thought markers are filtered out and routed into the existing provider-neutral ThinkingEvent. Any non-thought content after the marker is preserved. Version-agnostic: the fix holds regardless of your settings.json or Gemini CLI version.

PleasePrompto avatar Apr 21 '26 10:04 PleasePrompto