Repository navigation
fix(telegram): preserve forward origins in debounce batches - #108985
Conversation
9a658b1 to
7c45116
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 16, 2026, 1:40 PM ET / 17:40 UTC. Summary PR surface: Source +50, Tests +273. Total +323 across 6 files. Reproducibility: yes. On current main, enable Telegram inbound debounce and forward multiple messages with different origins within one window; source inspection shows the multi-entry synthetic message cannot retain those per-message origins, matching the linked report. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Next step before merge
Security Review detailsBest possible solution: Keep single-message forwarding metadata unchanged, but have multi-entry debounce batches preserve their ordered source messages and let the Telegram context owner apply per-segment visibility and attribution, as this patch does. Do we have a high-confidence way to reproduce the issue? Yes. On current main, enable Telegram inbound debounce and forward multiple messages with different origins within one window; source inspection shows the multi-entry synthetic message cannot retain those per-message origins, matching the linked report. Is this the best way to solve the issue? Yes. Passing original messages to the existing Telegram context owner is safer than prefixing text inside the debounce runtime because it preserves ordering, media placeholders, visibility filtering, and plain command parsing in their existing ownership boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cb84dc76fc05. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +50, Tests +273. Total +323 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (2 earlier review cycles)
|
19d0e34 to
472af1a
Compare
472af1a to
b18e238
Compare
|
Merged via squash.
|
…#108985) * fix(telegram): preserve forward origins in debounce batches * fix(telegram): deliver batched forward origins to agent * refactor(telegram): keep debounce forward cleanup local Co-authored-by: Arseniy Palagin <[email protected]> --------- Co-authored-by: Arseniy Palagin <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
When multiple Telegram messages arrive during an active agent turn, the inbound debounce spool merges them into one synthetic message built from the first entry, so only that entry's reply_to_message/quote survived. A quote-reply sent as a follow-up was silently dropped from the prompt. Give reply-target visibility a single owner and apply it to every buffered message, appending recovered targets to the reply chain keyed by message id. This mirrors the per-entry handling forward origins already received in openclaw#108985 in the same function. Closes openclaw#121765 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…#108985) * fix(telegram): preserve forward origins in debounce batches * fix(telegram): deliver batched forward origins to agent * refactor(telegram): keep debounce forward cleanup local Co-authored-by: Arseniy Palagin <[email protected]> --------- Co-authored-by: Arseniy Palagin <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Closes #108466
What Problem This Solves
Fixes an issue where Telegram users forwarding multiple messages within one inbound debounce window would lose per-message source attribution. Mixed and multi-origin batches could be presented to the agent as the forwarding user's own text or be attributed entirely to the first forwarded source.
Why This Change Was Made
The Telegram debounce path now carries the original messages into the Telegram context owner, which formats each segment with its own visible forward origin. Forward-origin visibility is evaluated per segment, the synthetic batch no longer inherits the first message's origin, and single-message debounce flushes retain their existing structured forwarding metadata. The agent-facing body is built from those attributed segments while the command body remains plain.
User Impact
Agents can distinguish ordinary text from forwarded content and identify each visible source correctly, including forwarded media-only segments. Group context-visibility rules continue to redact origins that are not allowed.
Evidence
Redacted live Telegram proof
Candidate
19d0e34bb247c610e9bd0411fb1820fd2ff81903was run with a temporary BotFather bot, an isolated candidate gateway/state/config/workspace, and a localhost-only deterministic OpenAI Responses mock. Two real text-only Telegram forwards from distinct public origins were sent in one burst.Observed pipeline:
2 real Bot API updates (38 ms apart) -> 1 debounce batch -> 1 dispatch -> 1 model POST -> 2 distinct forward origins in the current agent-facing turnRedacted runtime facts:
[Forwarded from ...]segments with two distinct origins in the current user turn, not history.After the proof, the branch was rebased onto current main
0903ebe4fa5f4643aaf83e3d59cc5518f80db448.git range-diffmarks both commits unchanged (=), the combined patch-id remains1dd854185e513d08949795a1749bf549112cef1d, and the six-file numstat is identical. Current head:472af1a2beb6f3d15fc767cb5df2a5052ef6bc39.Automated verification on current head
node scripts/run-vitest.mjs extensions/telegram/src/bot-message-context.forwarded-batch.test.ts extensions/telegram/src/bot.create-telegram-bot.test.tspnpm check:test-typespassed all three phases (core-test,extensions-test,root-test).git diff --check origin/main...HEADpassed.findings: [], patch correct, confidence0.88.AI-assisted: yes, implemented and reviewed with Codex. I reviewed the resulting code and understand the behavior and security boundary.