Skip to content

fix(telegram): filter reasoning segments when reasoningLevel is off#24518

Closed
avirweb wants to merge 1 commit intoopenclaw:mainfrom
avirweb:fix/telegram-reasoning-off-leak
Closed

fix(telegram): filter reasoning segments when reasoningLevel is off#24518
avirweb wants to merge 1 commit intoopenclaw:mainfrom
avirweb:fix/telegram-reasoning-off-leak

Conversation

@avirweb
Copy link
Copy Markdown
Contributor

@avirweb avirweb commented Feb 23, 2026

Problem

When users execute /reasoning off or /think off in Telegram, reasoning content
is still sent as separate messages. This happens because splitTextIntoLaneSegments()
extracts reasoning text from model output without checking if reasoning is disabled.

This is the Telegram-specific follow-up to issue #9563, which was previously fixed
for Discord in commit 14c54e6.

Root Cause

The splitTextIntoLaneSegments() function in bot-message-dispatch.ts always
creates reasoning segments when <think> tags or "Reasoning:" prefixes are found
in the model output. It doesn't respect the user's reasoningLevel setting.

// BEFORE: Always adds reasoning segments if text contains reasoning
if (split.reasoningText) {
  segments.push({ lane: "reasoning", text: split.reasoningText });
}

Solution

Filter out reasoning segments when resolvedReasoningLevel === "off". The
resolvedReasoningLevel variable is already available in scope (defined at line 144).

// AFTER: Only adds reasoning segments if reasoning is not explicitly disabled
if (split.reasoningText && resolvedReasoningLevel !== "off") {
  segments.push({ lane: "reasoning", text: split.reasoningText });
}

Changes

  • src/telegram/bot-message-dispatch.ts: Add resolvedReasoningLevel !== "off"
    condition to the reasoning segment check (1 line change)

Testing

  • Manual: Start conversation with reasoning-capable model (e.g., Kimi K2.5)
  • Run /reasoning off
  • Send a message that would normally trigger reasoning
  • Verify no separate "Reasoning:" message appears in Telegram
  • Verify answer content still appears correctly

Related Issues

Checklist

  • Surgical fix (minimal code change)
  • No breaking changes
  • Follows existing code patterns
  • Uses already-available variable in scope

When users execute /reasoning off or /think off, reasoning content
was still being sent as separate Telegram messages because the
splitTextIntoLaneSegments() function extracted reasoning text
regardless of the reasoningLevel setting.

This change filters out reasoning segments when resolvedReasoningLevel
is explicitly set to 'off', ensuring user intent is respected.

Fixes: openclaw#9563 (Telegram-specific)
Related: 14c54e6 (Discord fix)
@steipete
Copy link
Copy Markdown
Contributor

Thanks for the patch direction here.

I merged a superseding fix directly on main in 5a475259b that includes your core gate (reasoning off should suppress reasoning segments) plus an extra guard for the raw fallback path (reasoning-only payloads could still leak without that second guard).

Added regressions in src/telegram/bot-message-dispatch.test.ts for both mixed and reasoning-only payloads.

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

Labels

channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: /think off does not disable reasoning_content for reasoning-capable models

2 participants