openclaw - ✅(Solved) Fix [Feature] message tool should inherit session thread context in Telegram forum topics [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59023Fetched 2026-04-08 02:29:47
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
closed ×1cross-referenced ×1locked ×1

Fix Action

Fix / Workaround

当前 workaround

PR fix notes

PR #59634: fix(telegram): preserve topic thread when message replies include replyTo

Description (problem / solution / changelog)

Summary

Fix Telegram topic routing for message tool sends that include replyTo.

Today the Telegram plugin stops auto-inheriting the current topic/thread whenever replyToId is present. That breaks a common DM-topic / forum-topic flow:

  • the agent is replying inside a Telegram topic
  • the agent sends an attachment via message
  • the tool call includes replyTo
  • outbound send loses threadId
  • Telegram accepts the send, but posts it into the chat's main stream instead of the active topic

This PR keeps topic auto-thread inheritance active even when replyToId is present.

Root cause

In extensions/telegram/src/channel.ts, the plugin currently treats replyToId as a reason to suppress topic routing:

resolveAutoThreadId: ({ to, toolContext, replyToId }) =>
  replyToId ? undefined : resolveTelegramAutoThreadId({ to, toolContext })

For Telegram, these are different concerns:

  • replyToId answers which message to reply to
  • threadId answers which topic/thread the outbound message belongs to

Suppressing threadId when replyToId is present causes replies with attachments to fall out of the active topic.

Change

  • remove the replyToId ? undefined : ... guard
  • continue resolving topic threadId from the current Telegram context whenever the target chat still matches the current chat
  • add a regression test covering the failing replyToId path in a DM topic

Why this is safe

resolveTelegramAutoThreadId already checks that:

  • toolContext.currentThreadTs exists
  • toolContext.currentChannelId exists
  • the outbound target chat matches the current chat

So this does not force thread inheritance across chats. It only stops incorrectly dropping thread routing for same-chat replies.

Validation

Validated on a source checkout with:

  • pnpm test -- --run extensions/telegram/src/channel.test.ts extensions/telegram/src/action-threading.test.ts src/infra/outbound/message-action-runner.threading.test.ts
  • pnpm build

Related

Fixes #59023

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/telegram/src/action-threading.test.ts (modified, +10/-1)
  • extensions/telegram/src/action-threading.ts (modified, +3/-0)
  • extensions/telegram/src/channel.test.ts (modified, +28/-0)
  • extensions/telegram/src/channel.ts (modified, +2/-2)

Code Example

message(action=send, channel=telegram, target="-1003738032974", threadId="2", message="...")
RAW_BUFFERClick to expand / collapse

问题描述

在 Telegram Forum(多 topic 群组)里,当 agent session 本身处于某个 topic 中时,使用 message 工具发送消息,如果未显式指定 threadId,消息会默认发到主 topic,而不是当前 session 所在的 topic。

这导致:

  1. Agent 需要在每次调用 message 时都显式加 threadId 参数,容易遗漏
  2. 在不同 topic 里创建的新 session,每个都需要单独记住 threadId
  3. 用户感知上,agent"发错地方了",即使 agent 本身知道自己在哪个 topic 里

期望行为

message 工具在 Telegram channel 下,默认应该继承当前 session 的 thread context,即:

  • 如果当前 session 的 inbound context 来自某个 topic,自动使用该 topic 作为默认 threadId
  • 无需每次调用都显式指定 threadId
  • 只有当开发者明确指定 threadId 时,才覆盖默认值

当前 workaround

目前需要在每次 message 调用时显式传入 threadId,例如:

message(action=send, channel=telegram, target="-1003738032974", threadId="2", message="...")

这增加了 agent 的记忆负担,也容易出错。

使用场景

Telegram Forum(topic-based groups)是很多团队使用的工作群组织方式,thread 路由是核心功能。如果 message 工具能自动继承 session 的 thread 上下文,agent 的使用体验会大幅提升。

extent analysis

TL;DR

Modify the message tool to automatically inherit the current session's thread context by default, unless a threadId is explicitly specified.

Guidance

  • Identify the current session's inbound context to determine the default threadId for the message tool.
  • Update the message tool to use the default threadId from the current session's context, unless a threadId is explicitly provided.
  • Consider adding a configuration option to enable or disable this default behavior.
  • Test the updated message tool with various scenarios, including different topics and explicit threadId specifications.

Example

def message(action, channel, target, threadId=None, message=None):
    # Get the current session's inbound context
    session_context = get_session_context()
    
    # If no threadId is provided, use the default from the session context
    if threadId is None:
        threadId = session_context.get('threadId')
    
    # Send the message with the determined threadId
    send_message(action, channel, target, threadId, message)

Notes

This solution assumes that the get_session_context() function is available to retrieve the current session's inbound context. The implementation details may vary depending on the actual framework and libraries used.

Recommendation

Apply a workaround by modifying the message tool to automatically inherit the current session's thread context, as this will improve the agent's usability and reduce errors.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Feature] message tool should inherit session thread context in Telegram forum topics [1 pull requests, 1 participants]