Skip to content

fix(telegram): preserve rich forwarded message text#98735

Merged
obviyus merged 3 commits into
mainfrom
fix/telegram-rich-forward-body
Jul 1, 2026
Merged

fix(telegram): preserve rich forwarded message text#98735
obviyus merged 3 commits into
mainfrom
fix/telegram-rich-forward-body

Conversation

@obviyus

@obviyus obviyus commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Telegram messages delivered as rich messages could reach the agent as [unsupported Telegram rich_message received] instead of the visible message text.

This affected rich-message-only Telegram updates, including forwarded messages from clients where Telegram leaves text and caption empty but populates rich_message.

Why This Change Was Made

Telegram inbound body resolution now extracts visible text from rich_message.markdown, rich_message.html, and nested rich message blocks before falling back to the existing unsupported placeholder.

The same extraction path is used for the main inbound body, reply-target descriptions, and cached conversation context so rich-message text does not disappear in follow-up turns. Unsupported rich message shapes still keep the loud placeholder.

AI-assisted.

User Impact

Users can forward or send Telegram rich messages to the bot and have the agent see the actual message body. In requireMention groups, rich-message-only updates also participate in mention detection when the extracted rich text mentions the bot or matches configured mention patterns.

Evidence

Before-fix live repro on origin/main at 8d9a7ab2cab:

sent rich message 41658: RICH_FORWARD_MAIN_mr2d52u7 forwarded rich body text
observed SUT reply 41659
mock request promptHasRichText=false
mock request promptHasPlaceholder=true
excerpt: [unsupported Telegram rich_message received]

Focused tests after the fix:

node scripts/run-vitest.mjs extensions/telegram/src/bot-message-context.body.test.ts extensions/telegram/src/message-cache.test.ts extensions/telegram/src/bot/helpers.test.ts
Test Files  3 passed (3)
Tests       129 passed (129)

Other checks:

git diff --check
.agents/skills/autoreview/scripts/autoreview --mode local
autoreview clean: no accepted/actionable findings reported

After-fix live Telegram rerun was attempted, but the shared SUT bot token was being polled elsewhere:

Telegram getUpdates conflict: terminated by other getUpdates request

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M maintainer Maintainer-authored PR labels Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 2:25 PM ET / 18:25 UTC.

Summary
The PR extracts Telegram rich_message text for inbound message bodies, reply-target descriptions, mention checks, and cached conversation context instead of always using the unsupported placeholder.

PR surface: Source +87, Tests +215. Total +302 across 7 files.

Reproducibility: yes. at source level: current main returns the unsupported rich-message placeholder from inbound, reply, and cache paths when rich_message has no plain text or caption.

Review metrics: 1 noteworthy metric.

  • After-fix Telegram proof: 1 before-fix live repro, 0 successful after-fix live reruns. The Telegram maintainer note asks for real Telegram proof when reply context or transport-visible behavior changes.

Stored data model
Persistent data-model change detected: persistent cache schema: extensions/telegram/src/message-cache.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add summary extraction and regression coverage for Telegram details blocks.
  • [P1] Post a successful after-fix Telegram live run or artifact showing the forwarded rich text reaches the agent; redact private details before posting.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body includes a before-fix live repro and focused tests, but the attempted after-fix live Telegram rerun failed; post redacted after-fix terminal output, logs, live output, linked artifact, or recording, then update the PR body for a fresh review or ask a maintainer for @clawsweeper re-review.

Mantis proof suggestion
A live Telegram lane would directly prove the rich forwarded message reaches the agent as text after the fix. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live: verify a forwarded rich_message-only Telegram update reaches the agent as visible text instead of the unsupported placeholder.

Risk before merge

  • [P1] After-fix live Telegram proof is missing; the PR body shows a before-fix repro and focused tests, but the after-fix rerun hit a getUpdates conflict.
  • [P1] Details-block summaries can still be dropped from inbound, reply, and cache text if this lands as complete rich-message support.

Maintainer options:

  1. Fix summary extraction before merge (recommended)
    Add summary to the rich-block extraction path, cover details-only and details-with-body rich messages, then rerun focused Telegram tests and live proof.
  2. Accept partial rich-message support
    Maintainers could merge with details summaries still unsupported, but that would leave a known visible-text drop in the newly claimed rich-message path.

Next step before merge

  • [P1] The PR is draft/protected and needs contributor-visible code repair plus successful real Telegram proof, not an autonomous cleanup close.

Security
Cleared: The diff only changes Telegram message text extraction and focused tests; I found no concrete security or supply-chain regression.

Review findings

  • [P2] Render details summaries before falling back — extensions/telegram/src/bot/body-helpers.ts:160
Review details

Best possible solution:

Include all visible Bot API rich-message text fields, especially details summaries, add regression coverage, and provide successful after-fix Telegram proof before merge.

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

Yes at source level: current main returns the unsupported rich-message placeholder from inbound, reply, and cache paths when rich_message has no plain text or caption.

Is this the best way to solve the issue?

No: the shared helper is the right layer, but this patch is incomplete because it omits details summaries and lacks a successful after-fix live Telegram proof.

Full review comments:

  • [P2] Render details summaries before falling back — extensions/telegram/src/bot/body-helpers.ts:160
    Telegram rich details blocks have a visible summary, but this extraction only reads text, titles, captions, credits, and nested block arrays. A details-only rich message still falls back to the unsupported placeholder, and details-with-body messages drop the visible summary; add summary to extraction and cover it. (core.telegram.org)
    Confidence: 0.87

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 53fe2e4bc3ca.

Label changes

Label changes:

  • add P2: This is a normal-priority Telegram message-body bug fix with limited blast radius but real user-visible text loss.
  • add merge-risk: 🚨 message-delivery: The proposed extraction path can still suppress visible text from Telegram details summaries if merged as complete rich-message support.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes a before-fix live repro and focused tests, but the attempted after-fix live Telegram rerun failed; post redacted after-fix terminal output, logs, live output, linked artifact, or recording, then update the PR body for a fresh review or ask a maintainer for @clawsweeper re-review.
  • add mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram forwarded-message text and reply context, so a short Telegram live transcript or Desktop proof would materially help review.

Label justifications:

  • P2: This is a normal-priority Telegram message-body bug fix with limited blast radius but real user-visible text loss.
  • merge-risk: 🚨 message-delivery: The proposed extraction path can still suppress visible text from Telegram details summaries if merged as complete rich-message support.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes a before-fix live repro and focused tests, but the attempted after-fix live Telegram rerun failed; post redacted after-fix terminal output, logs, live output, linked artifact, or recording, then update the PR body for a fresh review or ask a maintainer for @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram forwarded-message text and reply context, so a short Telegram live transcript or Desktop proof would materially help review.
Evidence reviewed

PR surface:

Source +87, Tests +215. Total +302 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 99 12 +87
Tests 3 215 0 +215
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 314 12 +302

What I checked:

  • Repository policy applied: Root and scoped extension policy were read, and the Telegram maintainer note specifically requires real Telegram proof for Telegram behavior PRs that touch reply context. (.agents/maintainer-notes/telegram.md:37, 53fe2e4bc3ca)
  • Current main placeholder path: Current main only recognizes rich_message as an object and returns [unsupported Telegram rich_message received]; inbound, reply, and cache callers use that fallback when plain text/caption is absent. (extensions/telegram/src/bot/body-helpers.ts:96, 53fe2e4bc3ca)
  • PR branch reuse path: The branch adds rich-text extraction and reuses it from inbound body resolution, reply targets, and message cache body normalization. (extensions/telegram/src/bot-message-context.body.ts:280, b990f2a7a9be)
  • Missing rich-message field: renderRichBlocks reads text, title, subtitle, caption, credit, and several nested block arrays, but it does not read summary, so details block summaries are still dropped. (extensions/telegram/src/bot/body-helpers.ts:160, b990f2a7a9be)
  • Telegram rich-message contract: Telegram rich-message examples include <details><summary>…</summary>…</details>, and Bot API type docs expose RichBlockDetails.summary / RichBlock.summary as the disclosure summary for details blocks. (core.telegram.org)
  • Proof gap: The PR body includes a before-fix live repro and focused test output, but says the after-fix live Telegram rerun failed with a getUpdates conflict. (b990f2a7a9be)

Likely related people:

  • obviyus: Merged recent Telegram PRs fix(telegram): suppress fallback reply when plugin command returns suppressReply: true #80928, Restore Telegram /steer for active Codex runs #98126, and Add Telegram /login Codex pairing flow #98006, and authored adjacent native-command work touching extensions/telegram/src/bot-native-commands.ts. (role: recent Telegram reviewer/merger and adjacent contributor; confidence: medium; commits: a5e11c0083c5; files: extensions/telegram/src/bot-native-commands.ts, extensions/telegram/src/bot-native-commands.test.ts)
  • 100yenadmin: Authored recent merged Telegram work around active-run steering and Telegram login pairing, touching adjacent runtime/native-command files. (role: recent Telegram area contributor; confidence: medium; commits: bfc4e1dcb54c, 77edfe741489; files: extensions/telegram/src/sequential-key.ts, extensions/telegram/src/bot-native-command-deps.runtime.ts, extensions/telegram/src/bot-native-commands.ts)
  • masatohoshino: Current checkout blame attributes the rich-message placeholder and affected fallback lines to grafted commit 5ada3ac, but the associated PR is unrelated doctor work, so this is low-confidence routing only. (role: weak current-line blame signal; confidence: low; commits: 5ada3acb5a1a; files: extensions/telegram/src/bot/body-helpers.ts, extensions/telegram/src/bot-message-context.body.ts, extensions/telegram/src/bot/helpers.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Jul 1, 2026
@obviyus
obviyus marked this pull request as ready for review July 1, 2026 18:26
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 1, 2026
@obviyus
obviyus force-pushed the fix/telegram-rich-forward-body branch from b990f2a to 389d88b Compare July 1, 2026 18:27
@obviyus
obviyus merged commit 477b27b into main Jul 1, 2026
15 checks passed
@obviyus
obviyus deleted the fix/telegram-rich-forward-body branch July 1, 2026 18:27
@obviyus

obviyus commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Landed via rebase onto main.

  • Scoped tests: node scripts/run-vitest.mjs extensions/telegram/src/bot-message-context.body.test.ts extensions/telegram/src/message-cache.test.ts extensions/telegram/src/bot/helpers.test.ts -> 129 passed; git diff --check
  • Live proof: normal Telegram bot-to-bot mock-SUT path replied OPENCLAW_E2E_OK; rich-message path sent an inbound Telegram message with empty text/caption and rich_message present, mock prompt contained the rich marker, and mock prompt did not contain [unsupported Telegram rich_message received]
  • Review: branch autoreview clean, no accepted/actionable findings
  • Changelog: release-owned; not edited per repo policy
  • Land commit: 389d88b
  • Merge commit: 477b27b

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

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant