-
-
Notifications
You must be signed in to change notification settings - Fork 79.2k
Telegram forum-topic follow-up delivery can lose topic context when OriginatingTo is flattened #83302
Copy link
Copy link
Closed
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
Telegram forum-topic follow-up delivery can lose the specific topic context because some inbound Telegram topic code paths preserve
MessageThreadIdbut flattenOriginatingToback to plaintelegram:<chatId>instead of a topic-qualified target liketelegram:<chatId>:topic:<threadId>.This appears to affect non-General topics in forum groups more than the General topic.
Observed behavior
Relevant config during repro
messages.groupChat.visibleReplies = "automatic"channels.telegram.streaming.mode = "off"channels.telegram.replyToMode = "first"These config changes improved other symptoms but did not fully solve non-General topic behavior.
Diagnosis
In the installed runtime (
dist/bot-Ce301bOE.json v2026.5.7), I found multiple inbound Telegram forum-topic paths where:MessageThreadId/threadSpec.id/resolvedThreadIdwere preservedOriginatingToororiginatingTowas flattened to:telegram:<chatId>instead of preserving topic-qualified routing such as:
telegram:<chatId>:topic:<threadId>That creates a mismatch where downstream follow-up delivery can trust
OriginatingToand lose the topic target even though thread information still exists in the session context.Concrete local patch/workaround
I locally patched these cases to preserve topic-qualified routing:
Main inbound session context
OriginatingTo: \telegram:${chatId}``OriginatingTo: buildTelegramRoutingTarget(chatId, threadSpec)Mention-skip/internal hook context
originatingTo: \telegram:${chatId}``originatingTo: resolvedThreadId != null ? \telegram:${chatId}:topic:${resolvedThreadId}` : `telegram:${chatId}``Audio preflight context
OriginatingTo: \telegram:${chatId}``OriginatingTo: replyThreadId != null ? \telegram:${chatId}:topic:${replyThreadId}` : `telegram:${chatId}``After restart, the patched runtime was live and preserving topic-qualified
OriginatingTovalues.Why this seems like a real bug
This is separate from the documented reaction-update limitation where Telegram reactions lack thread IDs and forum-group reactions route to
:topic:1.The issue here is in normal message/topic handling: thread metadata exists, but some inbound context builders flatten the origin route anyway.
Request
Please review Telegram forum-topic inbound context and follow-up delivery paths to ensure topic-qualified
OriginatingTois preserved consistently wheneverthreadSpec.id/resolvedThreadId/MessageThreadIdis known.It would also help to add a regression test covering non-General Telegram forum topics where follow-up delivery must remain bound to the original topic.