Skip to content

fix(telegram,feishu): respect reasoningDefault config for reasoning stream previews#71817

Merged
obviyus merged 1 commit into
openclaw:mainfrom
anagnorisis2peripeteia:fix/respect-reasoning-default-config
May 8, 2026
Merged

fix(telegram,feishu): respect reasoningDefault config for reasoning stream previews#71817
obviyus merged 1 commit into
openclaw:mainfrom
anagnorisis2peripeteia:fix/respect-reasoning-default-config

Conversation

@anagnorisis2peripeteia

@anagnorisis2peripeteia anagnorisis2peripeteia commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Telegram and Feishu now honor configured reasoningDefault when deciding whether channel reasoning previews should stream or stay hidden.
  • Resolution order is session override, then normalized per-agent agents.list[].reasoningDefault, then global agents.defaults.reasoningDefault, then off.
  • Feishu remains stream-preview only: reasoningDefault: "on" is block-mode visibility, so it does not enable a live Feishu preview.

Addresses the Telegram/Feishu preview-default part of #73182. The broader /think billing/default behavior is separate.

Verification

  • pnpm test extensions/feishu/src/reasoning-preview.test.ts extensions/telegram/src/bot-message-dispatch.test.ts
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/tools/thinking.md extensions/feishu/src/agent-config.ts extensions/feishu/src/bot.ts extensions/feishu/src/reasoning-preview.test.ts extensions/feishu/src/reasoning-preview.ts extensions/telegram/src/agent-config.ts extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/bot-message-dispatch.ts
  • pnpm check:test-types

Notes

  • Rebased onto current main, dropped generated SDK docs/API/package export changes, and kept the fix inside the owning plugins.
  • Dropped unrelated Telegram draft-stream retry/backoff, network-error, host-hook, and unrelated forward-compat test changes.
  • WSL2 gateway inspected at ubuntu@100.79.136.128: OpenClaw 2026.5.6 with Telegram configured, but no reasoningDefault configured there, so it was not a useful live proof target without changing state.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram channel: feishu Channel integration: feishu size: S labels Apr 25, 2026
@greptile-apps

greptile-apps Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes resolveTelegramReasoningLevel and resolveFeishuReasoningPreviewEnabled to read reasoningDefault from the per-agent config as a fallback instead of hardcoding "off". Session-store overrides (including the newly handled explicit "off" level) still take precedence over the config default. The logic and call-site updates are correct; there is one minor semantic gap noted inline.

Confidence Score: 4/5

Safe to merge; logic is correct and existing behaviour is preserved — the only concern is a potential documentation/semantic gap for the "on" level in Feishu.

All test cases pass for the stated goals; the only unresolved question is whether reasoningDefault: "on" is intentionally a no-op for Feishu's streaming preview. If that's by design, this is a clean change; if not, it is an incomplete fix.

extensions/feishu/src/reasoning-preview.ts — specifically the configDefault === "stream" early-return when sessionKey is absent and the fallback at line 34.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/feishu/src/reasoning-preview.ts
Line: 19-21

Comment:
**`reasoningDefault: "on"` silently ignored for Feishu**

`configDefault === "stream"` only returns `true` for `"stream"`, so setting `reasoningDefault: "on"` in the agent config still produces `false` for Feishu's reasoning preview — identical to the pre-fix behaviour. The existing test on line 28-46 confirms this is currently intentional (`"on"` session level → `false`), but the PR description says both `"on"` and `"stream"` should be fixed. If `"on"` is genuinely meant to enable Feishu reasoning preview too, the condition should be `configDefault !== "off"` (mirroring the Telegram side). If Feishu only supports the streaming variant, a brief code comment would prevent future confusion.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: respect reasoningDefault config in ..." | Re-trigger Greptile

Re-review progress:

Comment on lines 19 to 21
if (!params.sessionKey) {
return false;
return configDefault === "stream";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 reasoningDefault: "on" silently ignored for Feishu

configDefault === "stream" only returns true for "stream", so setting reasoningDefault: "on" in the agent config still produces false for Feishu's reasoning preview — identical to the pre-fix behaviour. The existing test on line 28-46 confirms this is currently intentional ("on" session level → false), but the PR description says both "on" and "stream" should be fixed. If "on" is genuinely meant to enable Feishu reasoning preview too, the condition should be configDefault !== "off" (mirroring the Telegram side). If Feishu only supports the streaming variant, a brief code comment would prevent future confusion.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/reasoning-preview.ts
Line: 19-21

Comment:
**`reasoningDefault: "on"` silently ignored for Feishu**

`configDefault === "stream"` only returns `true` for `"stream"`, so setting `reasoningDefault: "on"` in the agent config still produces `false` for Feishu's reasoning preview — identical to the pre-fix behaviour. The existing test on line 28-46 confirms this is currently intentional (`"on"` session level → `false`), but the PR description says both `"on"` and `"stream"` should be fixed. If `"on"` is genuinely meant to enable Feishu reasoning preview too, the condition should be `configDefault !== "off"` (mirroring the Telegram side). If Feishu only supports the streaming variant, a brief code comment would prevent future confusion.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing Greptile: This is intentional. Feishu reasoning preview only supports the stream variant — on means block-mode reasoning (delivered after completion), which has no live preview equivalent in Feishu. Added a clarifying comment in 01b2bec.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69e419c3c0

ℹ️ 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".

@@ -188,8 +188,16 @@ function resolveTelegramReasoningLevel(params: {
telegramDeps: TelegramBotDeps;
}): TelegramReasoningLevel {
const { cfg, sessionKey, agentId, telegramDeps } = params;

// Resolve config-driven default: per-agent override > hardcoded "off".
const agentDefault = cfg.agents?.list?.find((a) => a.id === agentId)?.reasoningDefault;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize agent IDs before applying reasoningDefault

agentId here comes from routing, and resolveAgentRoute normalizes IDs via pickFirstExistingAgentId/sanitizeAgentId, so it is lowercase even if agents.list[].id was configured as mixed case. This case-sensitive lookup (a.id === agentId) can miss the configured agent entry and silently fall back to "off", so the new reasoningDefault fallback still does not work for valid mixed-case configs. The same pattern is also present in extensions/feishu/src/reasoning-preview.ts.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point, but this case-sensitive lookup matches the existing pattern used elsewhere in the codebase (e.g. resolveAgentOutboundIdentity, directive resolution). Adding normalisation here alone would be inconsistent. Would be worth a separate issue to normalise agent ID lookups across the board if maintainers agree — happy to file one.

@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor Author

CI note: The 3 failing checks (extension-fast-memory-core, checks-node-extensions-shard-5, checks-node-extensions) are unrelated to this PR — our changes only touch extensions/telegram/ and extensions/feishu/. The failures are in memory-core/dreaming-phases.test.ts, gateway-lock.test.ts, and media-tool-shared.test.ts, which are pre-existing flaky tests also failing on main.

Re: Greptile comment on Feishu "on" behaviour — this is intentional. Feishus reasoning preview only supports the streaming variant (inline text updates in the message). Setting reasoningDefault: "on"means block-mode reasoning, which Feishu cannot render, so it correctly returnsfalse. Telegram handles both "on"and"stream"` because it can render reasoning in either mode. Added a clarifying comment in the code.

@anagnorisis2peripeteia anagnorisis2peripeteia changed the title fix(telegram,feishu): respect reasoningDefault config as fallback fix(telegram,feishu): enable Claude CLI reasoning via reasoningDefault config Apr 26, 2026
@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
Review failed before ClawSweeper could summarize the requested change.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Real behavior proof
Not applicable: Real behavior proof was not assessed because the Codex review failed.

Next step before merge
Review did not complete, so no work-lane recommendation was made.

Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Codex review failed for this PR with exit 1.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)

Remaining risk / open question:

  • No close action taken because the review did not complete.

Codex review notes: model gpt-5.5, reasoning high; reviewed against bc720dedaf0e.

@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor Author

Hey @obviyus — sorry for the delay, I wasn't aware I needed to manually ping a maintainer after addressing the bot feedback. The Greptile concern about Feishu "on" has been explained in a prior comment (intentional — Feishu preview only supports streaming mode). Tests all pass, CI failures are pre-existing flakes unrelated to this PR. Would appreciate a look when you get a chance!

@clawsweeper

clawsweeper Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge.

What this changes:

The PR updates Telegram and Feishu reasoning-preview resolution to use agents.list[].reasoningDefault as a fallback, passes config and agent IDs into Feishu call sites, and adds extension tests for config fallback and explicit session off behavior.

Maintainer follow-up before merge:

This is an open contributor implementation PR for a real current-main gap, but the remaining action is maintainer/channel-owner review and a small branch update decision rather than an autonomous replacement repair.

Review findings:

  • [P2] Use the shared reasoning-default resolution — extensions/feishu/src/reasoning-preview.ts:11-13
Review details

Best possible solution:

Update the branch so Telegram and Feishu resolve the same effective reasoning default that current main exposes: explicit session state first, then normalized per-agent default, then global default, then off, while preserving Feishu’s stream-only preview behavior and adding focused tests for normalized agent IDs, global defaults, and explicit session off.

Full review comments:

  • [P2] Use the shared reasoning-default resolution — extensions/feishu/src/reasoning-preview.ts:11-13
    The new fallback does a raw agents.list equality check and stops there. Routed agent IDs are normalized, and current main now also supports agents.defaults.reasoningDefault, so valid configs such as an Ops agent routed as ops or a global reasoningDefault: "stream" still fall back to off in these channel previews. Please resolve the effective agent config through the shared normalized resolver and include the global default with matching precedence.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.87

Acceptance criteria:

  • pnpm test extensions/telegram/src/bot-message-dispatch.test.ts
  • pnpm test extensions/feishu/src/reasoning-preview.test.ts
  • pnpm test extensions/feishu/src/bot.test.ts
  • pnpm check:changed in Testbox before merge if maintainers proceed

What I checked:

Likely related people:

  • vincentkoc: GitHub history ties Vincent Koc to the Feishu stream-only reasoning preview helper and to the per-agent defaults work that introduced agents.list[].reasoningDefault. (role: introduced Feishu reasoning-preview behavior and per-agent defaults; confidence: high; commits: d609f71c9b74, c96a12aeb9e8; files: extensions/feishu/src/reasoning-preview.ts, extensions/feishu/src/bot.ts, src/auto-reply/reply/directive-handling.levels.ts)
  • obviyus: GitHub history and the PR discussion connect obviyus to Telegram reply/preview work and to the merged core fix that made reasoningDefault independent of thinking state. (role: Telegram reasoning and core reasoningDefault maintainer route; confidence: high; commits: b91374eb0d7b, dc3b10285db8; files: extensions/telegram/src/bot-message-dispatch.ts, src/auto-reply/reply/directive-handling.levels.ts)
  • deepujain: Current main includes Deepak Jain’s merged global agents.defaults.reasoningDefault work, which now affects the correct fallback contract this PR should align with. (role: recent global reasoningDefault implementer; confidence: medium; commits: 0c9f84451a9f; files: src/auto-reply/reply/get-reply-directives.ts, src/config/types.agent-defaults.ts, docs/gateway/config-agents.md)
  • steipete: Recent GitHub path history shows Peter Steinberger maintaining the affected Telegram dispatch path and config/runtime-adjacent surfaces near this PR. (role: recent channel/config-adjacent maintainer; confidence: medium; commits: cb8c513ce3f2, 4336a7f3a9c6; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/feishu/src/bot.ts)

Remaining risk / open question:

  • The PR was written before current main added agents.defaults.reasoningDefault, so maintainers need to decide whether the branch should be updated to the current fallback contract before merge.
  • The channel preview fallback should stay aligned with core reasoning authorization semantics so configured reasoning visibility is not exposed in contexts where core intentionally resolves it to off.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 3215ab6de5db.

@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor Author

CI failures on this run appear to be infrastructure flakes unrelated to the PR changes:

  • checks-node-agentic-control-plane: gateway device approval timeout (SIGTERM/143)
  • checks-node-core-runtime-infra: src/infra/dotenv.test.ts failure — unrelated to Telegram/Feishu
  • checks-node-channels / checks-node-core: cascade from the above

Could a maintainer re-run the failed checks? Happy to investigate further if any failure turns out to be related to the PR.

@anagnorisis2peripeteia anagnorisis2peripeteia force-pushed the fix/respect-reasoning-default-config branch from c53c601 to 500e68e Compare April 29, 2026 19:47
@anagnorisis2peripeteia anagnorisis2peripeteia force-pushed the fix/respect-reasoning-default-config branch from 538dd4f to 9606b0b Compare April 29, 2026 22:50
@anagnorisis2peripeteia anagnorisis2peripeteia force-pushed the fix/respect-reasoning-default-config branch from 2eb00ac to 97b4e7e Compare April 29, 2026 23:59
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Apr 29, 2026
@anagnorisis2peripeteia anagnorisis2peripeteia force-pushed the fix/respect-reasoning-default-config branch from 3d9f3c2 to afe2850 Compare April 30, 2026 22:45
@anagnorisis2peripeteia anagnorisis2peripeteia force-pushed the fix/respect-reasoning-default-config branch from 7b9602f to ea1cd0a Compare May 2, 2026 15:46
@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor Author

Re the ClawSweeper P2 on 'Use the shared reasoning-default resolution':

The P2 says the fallback does a raw agents.list equality check, but that is not the case on this branch. src/plugin-sdk/agent-config-helpers.ts (added in this PR) provides resolveConfigReasoningDefault, which:

  1. Calls resolveAgentConfig(cfg, agentId) — that function calls normalizeAgentId(agentId) on both sides of the comparison, so case-insensitive / routed IDs work correctly.
  2. Falls back to cfg.agents?.defaults?.reasoningDefault for the global default.

Both behaviours are covered by tests in extensions/feishu/src/reasoning-preview.test.ts:

  • 'matches agent ID case-insensitively' (line 137)
  • 'uses global agents.defaults.reasoningDefault when no per-agent entry matches' (line 153)
  • 'per-agent reasoningDefault takes precedence over global default' (line 170)

@anagnorisis2peripeteia anagnorisis2peripeteia force-pushed the fix/respect-reasoning-default-config branch from 7540f67 to 6f29f55 Compare May 2, 2026 21:56
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label May 2, 2026
@anagnorisis2peripeteia anagnorisis2peripeteia force-pushed the fix/respect-reasoning-default-config branch from 9bdff50 to 5ca5e73 Compare May 2, 2026 22:07
@anagnorisis2peripeteia

anagnorisis2peripeteia commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (2fd1e7b), resolved baseline conflicts, and dropped stale retrigger commits.

Also fixed two upstream oxlint regressions from f6f8d74 (lifecycle.ts unnecessary String() cast, task-registry.maintenance.ts map-spread) that were breaking CI lint.

Full CI (pull_request workflow) triggered successfully on the first rebase push and only failed due to those upstream lint issues -- all other checks passed. Subsequent pushes with the lint fix only trigger pull_request_target workflows (auto-response, labeler, dispatch). May need a maintainer to approve/re-run the CI workflow for the latest HEAD.


Update (May 7): Stripped verbose reasoning level entirely -- never deployed to production. The shipped dist uses "stream" only; tool actions are surfaced via status reactions (setTool), not reasoning text markers.

Changes since rebase:

  • Removed verbose from TelegramReasoningLevel type ("off" | "on" | "stream")
  • Deleted verboseReasoningActions flag, activeVerboseActions Map, pushVerboseReasoningAction helper, and all 5 call sites
  • Updated docs/tools/thinking.md -- reasoning visibility levels now on|off|stream
  • Simplified streamReasoningDraft to resolvedReasoningLevel === "stream"

All 35 draft-stream tests pass. HEAD is fae01584ca. ClawSweeper P3s about verbose are now moot; awaiting re-scan.

@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor Author

Combined test branch available: 5.6+claude-cli-telegram-reasoning based on v2026.5.6 with both #71817 and #74508 cherry-picked on top.

If you'd like to try both fixes together:

npm install -g anagnorisis2peripeteia/openclaw#5.6+claude-cli-telegram-reasoning

What's included:

  • reasoningDefault config now respected for Telegram/Feishu -- set "reasoningDefault": "stream" in openclaw.json and Claude's extended thinking streams in channel replies without needing /reasoning stream per session
  • Reasoning overflow chains to a new message instead of truncating
  • Adaptive throttle with account-wide 429 backoff propagation
  • QQBot SSRF guard on API endpoints

Feedback welcome -- especially on how the reasoning stream behaves during long thinking blocks and whether the overflow chaining feels natural.

@obviyus

obviyus commented May 8, 2026

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

  • Scoped tests: pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/tools/thinking.md extensions/feishu/src/agent-config.ts extensions/feishu/src/bot.ts extensions/feishu/src/reasoning-preview.test.ts extensions/feishu/src/reasoning-preview.ts extensions/telegram/src/agent-config.ts extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/bot-message-dispatch.ts; pnpm test extensions/feishu/src/reasoning-preview.test.ts extensions/telegram/src/bot-message-dispatch.test.ts; pnpm check:test-types
  • Changelog: CHANGELOG.md updated
  • Land commit: 5001cd4
  • Merge commit: 30e079d

Thanks @anagnorisis2peripeteia!

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

Labels

channel: feishu Channel integration: feishu channel: telegram Channel integration: telegram docs Improvements or additions to documentation size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants