Repository navigation
fix(telegram): forum approval drops the topic when the live turn omits it - #192162
Conversation
A plugin approval started in a Telegram forum topic can carry the group on the live turn and the topic only on the stored session. Exact origin matching treated the missing thread as a conflict and dropped the origin, so the prompt went to the approver DM. When the chat matches and only one side has a thread, keep that thread. Two different threads still do not route.
The new resolver option is part of the public origin helper, so the channel approvals doc lists it with the other options. The core comment no longer describes Telegram threads, and the hook is passed through without normalizing targets a second time.
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
|
Codex review: needs maintainer review before merge. What this changesThis PR normalizes live and stored Telegram topic routes through the same parser before approval-origin matching. Example: An approval originates in group -1003841603622, topic 928, with a stored route of telegram:-1003841603622:topic:928.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a current forum approval-routing defect with a focused Telegram-local change and convincing delivery evidence; the earlier SDK finding is resolved. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherTelegram's approval adapter interprets live request metadata and stored session delivery routes, then supplies a destination to the shared approval planner and Telegram transport. flowchart TD
A[Live approval request] --> C[Telegram target parser]
B[Stored session route] --> C
C --> D[Shared account and origin matching]
D --> E[Native delivery planner]
E --> F[Telegram forum topic]
E --> G[Approver DM fallback]
Technical reviewBest possible solution: Land the Telegram-local normalization repair while retaining shared account eligibility and exact topic-conflict rejection. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the route-representation mismatch, and supplied Gateway-to-Telegram traces demonstrate its DM fallback; this read-only review executed no target code. Is this the best way to solve the issue? The revised patch fixes normalization at the existing Telegram adapter, removes the earlier public reconciliation callback, and preserves the shared consistency invariant. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 77a0a8426513. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +10, Tests +41, Other +2. Total +53 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 13, 2026, 2:28 PM ET / 19:28 UTC (Revision 2). |
|
Related private-DM case: #197907 has the original Telegram screenshot and a sanitized incident report. The request came from a topic inside the approver's own private chat, but the card appeared outside that topic; the topic then said the approval had been sent to DMs “not this chat.” This is a system-agent approval, and its source route already carried a topic. That differs from the missing group-forum thread in this PR, so I am not claiming this change fixes our case. We are tracing the configured approver-DM target separately and keeping other approvers and group privacy unchanged. |
|
Opened the complementary private bot-topic fix in #198038. This case already has an origin topic, but the same user's approver-DM destination loses it. The patch keeps the topic only for the same numeric private chat and confirmed bot account, and avoids the misleading root-DM notice. It does not replace this PR's missing-forum-origin fix. The original screenshot and 59 passing focused tests are in the new PR; no live post-fix client result is claimed. |
The approval origin check compared the live turn, parsed to the bare chat id, with the stored session route, which keeps the `telegram:<chat>:topic:<id>` form. The pair never matched, so approvals from a forum topic with `execApprovals.target: "channel"` fell back to the approver DM. Normalize both sides through one Telegram origin-target parser and drop the public reconcileDivergentTargets callback: the live turn does carry the topic. Co-authored-by: obviyus <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…s it (openclaw#192162) * fix(telegram): keep forum topic when an approval turn omits the thread A plugin approval started in a Telegram forum topic can carry the group on the live turn and the topic only on the stored session. Exact origin matching treated the missing thread as a conflict and dropped the origin, so the prompt went to the approver DM. When the chat matches and only one side has a thread, keep that thread. Two different threads still do not route. * fix(telegram): document the omitted-thread approval hook The new resolver option is part of the public origin helper, so the channel approvals doc lists it with the other options. The core comment no longer describes Telegram threads, and the hook is passed through without normalizing targets a second time. * fix(telegram): match stored forum topic routes for approval origins The approval origin check compared the live turn, parsed to the bare chat id, with the stored session route, which keeps the `telegram:<chat>:topic:<id>` form. The pair never matched, so approvals from a forum topic with `execApprovals.target: "channel"` fell back to the approver DM. Normalize both sides through one Telegram origin-target parser and drop the public reconcileDivergentTargets callback: the live turn does carry the topic. Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: obviyus <[email protected]>
* fix(telegram): keep DM topic approvals in their conversation * fix(telegram): avoid duplicate terminal approval replies Wait for an approver card in the originating topic before sending a fallback result. Keep terminal button cleanup for every approver and send one fallback to the origin only if its card edit fails. Cover requester-first and requester-second fanout, expiry and deleted origin cards through the real approval handler. --------- Co-authored-by: obviyus <[email protected]> (cherry picked from commit 129ccc3) Release adaptation: retain the release runtime dependency seams and existing unit cases; add the private-topic integration regressions as a separate file. Bring only the prerequisite topic-aware pending-target identity from #137438 (6a6fa4d), using existing routing helpers, rather than its broader changes. Use the existing async native approval capability so its async Telegram resolver and runtime are actually invoked; no new storage internals are added. Companion closure: #192162 fixes forum-origin normalization, not this private DM numeric origin, and is not required. Proof: source/route review and node --check passed. Runtime tests are blocked by missing worktree dependencies; no dependency installation was attempted. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit a427f5c9511eb3aa972c8b56d4fcc39efdf02f77)
Port Telegram callbacks, hook session keys, private-topic approvals and interactive widgets with complete send/edit/route security companions. Include Feishu captioned media, iOS permission Sendable callbacks, WebKit animation/menu retirement and pending automations props handling. Keep Matrix malformed formatted-mention parsing linear-time. Adapt the 11.4 equivalents to the fixed beta baseline where available. Source PRs: #196217, #191585, #196822, #194027, #197519, #198038, #196991, #198380, #198658, #184432. Companion scope: #191647, #192162, #198022, #197271, #194146; #197670 is folded into #197519 equivalent. (cherry picked from commit 928c118) (cherry picked from commit 569ca48) (cherry picked from commit efa744e) (cherry picked from commit c301da9) (cherry picked from commit 641c4d5) (cherry picked from commit b9d3fb4) (cherry picked from commit a213a51) (cherry picked from commit ec46689) (cherry picked from commit 779d22e) (cherry picked from commit 129ccc3) (cherry picked from commit 849c050) (cherry picked from commit b22f35f) (cherry picked from commit 8b414e9) (cherry picked from commit 01ecda4) (cherry picked from commit f978e54) (cherry picked from commit 6e60479) (cherry picked from commit ec7b49a) (cherry picked from commit 1d72ad0) (cherry picked from commit 5e2c66f) (cherry picked from commit dfb6454) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f7c581c7f8bf0e57c7d8799e928a121b24462450) Co-authored-by: vincentkoc <[email protected]>
Closes #125166
What Problem This Solves
With
execApprovals.target: "channel", an exec or plugin approval started in a Telegram forum topic is sent to the approver's private DM instead of the topic. The topic shows nothing, so the user in the topic does not see that the tool is waiting.User Impact
The approval card is posted in the forum topic where the request started, as
target: "channel"promises. A live turn from a different topic still does not match the stored route, so no card goes to a topic the request did not come from.Why This Change Was Made
The origin check compares the live turn target with the stored session route and refuses the origin when they differ. Both carry the same topic, but in different shapes:
{ to: "<chat>", threadId: 3 };{ to: "telegram:<chat>:topic:3", threadId: 3 }, because the session resolver only rannormalizeTelegramChatId, which rejects the:topic:form.The pair never matched, the origin resolved to null, and the planner fell back to the approver DM. The live turn does carry its topic, so the omitted-thread theory in the first revision did not match the real flow.
The Telegram adapter now normalizes the live turn and the stored session through one parser (
toTelegramOriginTarget). The publicreconcileDivergentTargetscallback, its core plumbing and docs from the first revision are removed, so there is no SDK change. A stored target that cannot be parsed still has to disagree with the live turn.Evidence
Live Telegram Test Server E2E, real Gateway + deterministic mock model, leased QA user, run-owned forum (
--create-forum),execApprovals: { enabled: true, approvers: [<qa user>], target: "channel" },tools.exec.mode: "ask". The user sendsEXEC:/usr/bin/touch ...in the forum topic and taps Allow Once. The Bot API proxy log shows where eachsendMessagewent.mainat8ebe740925ca: the cardApproval required ...went to the private chat (chat: private, no topic). The topic only gotWorking / Exec running, and the tap found no button. The same happened for a plugin approval (before_tool_call→requireApproval).mainlogged the origin check inputs: live turn{"to":"-100…","threadId":3}, stored session{"to":"telegram:-100…:topic:3","threadId":3}.ff04a839e875: the exec approval card was posted in the forum topic, the Allow Once tap edited that card, the command ran andEXEC_DONEarrived in the topic. A plugin approval (🛡️ Plugin approval required) was also posted in the topic and resolved by a tap there. Nothing went to the private chat.approval-native.test.tsstores the realtelegram:<chat>:topic:<id>route; the same-topic case fails onmainand passes here, the different-topic control stays null.Bot API proxy log (chat kind, topic id, text prefix)
main8ebe740:This head ff04a83 (exec approval, then plugin approval; the last card is the exec approval that follows the plugin approval, left untapped):
Captured Telegram events at this head (TDLib recorder on the QA user)