fix(telegram): add reasoning filter to slash command delivery path#38689
fix(telegram): add reasoning filter to slash command delivery path#38689okuyam2y wants to merge 1 commit intoopenclaw:mainfrom
Conversation
bot-native-commands.ts handles slash commands (/reset, /model, etc.) via dispatchReplyWithBufferedBlockDispatcher, but its deliver callback had no reasoning text filtering. bot-message-dispatch.ts (regular messages) already filters via splitTelegramReasoningText. This causes Gemini Flash thinking content (delivered as <think> tags in text) to leak to Telegram users after slash commands like /reset, even when reasoning display is off. Add splitTelegramReasoningText filtering to the deliver callback: - Pure reasoning text → skip delivery (or deliver media with empty text) - Mixed reasoning + answer → deliver answer only Relates: openclaw#37890, openclaw#26466 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d7d6a73fa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } else { | ||
| return; |
There was a problem hiding this comment.
Avoid dropping slash replies that start with "Reasoning:"
This new early return can silently suppress valid slash-command output because it relies on splitTelegramReasoningText, which currently classifies any text beginning with Reasoning:\n as reasoning-only (splitTelegramReasoningText in src/telegram/reasoning-lane-coordinator.ts, lines 71-75). In scenarios where a user prompt intentionally asks for a response section titled “Reasoning:” and no media is attached, this branch exits before deliverReplies is called, so Telegram receives no message at all.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR fixes a reasoning text leak in Telegram's slash command delivery path. The fix adds The implementation correctly handles the core cases:
The change is a single-function, targeted fix that mirrors an established production-validated pattern. Slash commands always suppress reasoning text (no Confidence Score: 5/5
Last reviewed commit: 8d7d6a7 |
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Closing — this fix has been independently merged into upstream main (same code at bot-native-commands.ts L714-743, including the import at L74). Thanks! |
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…aw#38689) Match bot-message-dispatch.ts behavior: reasoning-only payloads with media deliver media with empty text instead of being silently dropped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
bot-native-commands.tshandles slash commands (/reset,/model, etc.) viadispatchReplyWithBufferedBlockDispatcher, but itsdelivercallback had no reasoning text filtering. Gemini Flash thinking content (delivered as<think>tags in text) leaks to Telegram users after slash commands, even when reasoning display is off.Reasoning:\n_thinking content_) in Telegram after/resetand other slash commands.splitTelegramReasoningTextfiltering to the slash commanddelivercallback, matching the behavior already present inbot-message-dispatch.ts(regular messages). Reasoning-only payloads with media still deliver media with empty text.bot-message-dispatch.ts(regular message path),reasoning-lane-coordinator.ts(split logic), reasoning level configuration. Slash commands always suppress reasoning text (no/reasoning onsupport in this path).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Slash command responses in Telegram no longer include leaked reasoning/thinking text from Gemini Flash models when reasoning display is off (the default).
Security Impact (required)
Repro + Verification
Environment
google/gemini-2.5-flash(Google AI native provider)thinkingDefault: off,reasoningLevel: off(default)Steps
/resetin Telegram DMExpected
Only the greeting text appears (e.g. "Hello! Is there anything I can help you with?")
Actual (before fix)
A separate message with
Reasoning:\n_The user has started a new session..._appears before the greetingEvidence
Raw stream log before fix shows
<think>content intext_deltaevents, and the text delivered to Telegram includes reasoning prefix. After fix, only answer text is delivered.The key diagnostic:
appendRawStreamdebug logging inbot-message-dispatch.tsshowed zerotg_events for/resetresponses, proving the delivery went throughbot-native-commands.tsinstead — which had no reasoning filter.Human Verification (required)
/resetwith Gemini 2.5 Flash on Telegram — reasoning text no longer appearsbot-message-dispatch.tsbehavior)delivercallback)Compatibility / Migration
Failure Recovery (if this breaks)
src/telegram/bot-native-commands.tssplitTelegramReasoningTextfalse-positiving on non-reasoning text)Risks and Mitigations
splitTelegramReasoningTextcould false-positive on legitimate text starting with "Reasoning:" prefixbot-message-dispatch.tswhich has been running in production. The split function uses specific pattern matching (Reasoning:\n_..._) not a broad substring match./reasoning onsettingresolvedReasoningLevel.