Skip to content

fix(telegram): preserve exact whitespace in selected reply quotes - #129254

Merged
steipete merged 1 commit into
mainfrom
codex/qa-telegram-exact-quote-20260825
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-telegram-exact-quote-20260825

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Telegram selected replies could quote the wrong passage or fail to send when the selected text began or ended with spaces, tabs, or newlines.

Why This Change Was Made

Telegram requires a quote to be an exact substring of the original message, but both OpenClaw action-ingress owners trimmed it before the existing Telegram sender received the value. Preserve the exact quote bytes through both direct actions and durable channel payloads while retaining the sender's existing whitespace-only rejection.

Production delta: 2 additions / 2 deletions (net 0). No configuration, protocol, authentication, persistence, plugin-SDK, or dependency changes.

User Impact

Telegram reply quotes now match the text the user or agent actually selected, including meaningful leading/trailing whitespace and newlines, for both standard and snake-case action parameters.

Evidence

  • Direct installed Telegram dependency contract states that a quote must be an exact substring or the message fails to send.
  • Authentic pre-fix direct-action and durable-payload regressions failed for both camel-case and snake-case quoted text.
  • Focused action, durable contract, and provider reply-parameter suites: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/telegram/src/action-runtime.test.ts extensions/telegram/src/channel-actions.contract.test.ts extensions/telegram/src/reply-parameters.test.ts --reporter=dot — 149 passed.
  • Real Telegram sender-path regression and rejected-native-quote fallback: 2 additional passing tests.
  • Scoped type-aware lint and formatting passed; fresh independent structured review was clean.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS maintainer Maintainer-authored PR labels Aug 25, 2026
@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 7:50 AM ET / 11:50 UTC.

ClawSweeper review

What this changes

Preserves leading and trailing whitespace in Telegram selected-reply quotes for direct actions and durable channel payloads.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still trims selected Telegram quote text in both ingress paths, while this focused PR preserves it and the prior proof blocker is now satisfied by real Telegram evidence. The PR is maintainer-authored/labeled, so it should remain for normal maintainer merge handling.

Priority: P2
Reviewed head: df50e071f912f9ef1744434f820eba3efd754207

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused root-cause repair has strong real Telegram evidence and appropriate sibling-path coverage.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Mantis supplied before/after real Telegram Desktop and Bot API evidence for both direct and durable paths; the local prepared previews also show the selected-reply flow.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Mantis supplied before/after real Telegram Desktop and Bot API evidence for both direct and durable paths; the local prepared previews also show the selected-reply flow.
Evidence reviewed 5 items Current-main root cause: Current main uses the shared string reader with its default trimming behavior for direct Telegram sends; the reader defaults trim to true and applies raw.trim().
Durable-path sibling: Current main independently applies the same default-trimming reader before storing Telegram channel data for durable presentation delivery.
Sender invariant retained: The downstream sender still rejects whitespace-only quotes using a trim-only presence check while retaining nonblank quote bytes unchanged.
Findings None None.
Security None None.

Live Verification

Command: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/telegram/src/action-runtime.test.ts extensions/telegram/src/channel-actions.contract.test.ts extensions/telegram/src/reply-parameters.test.ts --reporter=dot

Result: FAIL (partial) — step 2 expect_output passed: expected terminal output was not visible within 30 seconds: "passed"

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/telegram/src/action-runtime.test.ts extensions/telegram/src/channel-actions.contract.test.t
s extensions/telegram/src/reply-parameters.test.ts --reporter=dotrunner@runnervm76f27:/tmp/clawsweeper-live-proof-129254-t5dz5D/target$ OPENCLAW_VITEST_MAX_WORK
ERS=1 node scripts/run-vitest.mjs extensions/telegram/src/action-runtime.test.ts extensions/telegram/src/channel-actions.contract.test.ts extensions/telegram/sr
c/reply-parameters.test.ts --reporter=dot
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/telegram/src/action-runtime.test.ts extensions/telegram/src/channel-actions.contract.test.t
s extensions/telegram/src/reply-parameters.test.ts --reporter=dot
[test] starting test/vitest/vitest.extension-telegram.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129254-t5dz5D/target










































Assertions:

  • FAIL expect_output: passed

How this fits together

Telegram message actions convert model or channel payload parameters into Bot API send requests. Quote text must reach the sender unchanged so Telegram can match the intended source substring.

flowchart LR
  A[Message action] --> B[Telegram action ingress]
  B --> C[Quote text preparation]
  C --> D[Telegram sender]
  D --> E[Telegram Bot API]
  E --> F[Selected reply in chat]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind current main; recheck the exact merge result and required checks before landing.
  • Complete next step (P2) - This maintainer-authored open PR has sufficient proof and no discrete repair finding for an automated work lane.
Agent review details

Security

None.

PR surface

Source 0, Tests +16. Total +16 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 2 2 0
Tests 2 23 7 +16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 25 9 +16

Review metrics

Metric Value Why it matters
Production versus test delta production +2/-2; tests +23/-7 The bug fix is production-net-neutral and adds direct and durable-path regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the net-neutral ingress repair after exact-head merge/check verification, retaining the sender’s existing whitespace-only quote rejection.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the net-neutral ingress repair after exact-head merge/check verification, retaining the sender’s existing whitespace-only quote rejection.

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

Yes: the attached real Telegram baseline and candidate run exercises both ingress paths with a whitespace-padded repeated substring and records the sent quote bytes.

Is this the best way to solve the issue?

Yes: disabling trimming at the two ingress owners while retaining the sender’s whitespace-only rejection fixes the root cause without adding a parallel path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1fdd10bf6aa5.

Labels

Label justifications:

  • P2: Whitespace-trimmed quote selections can target a wrong repeated passage or fail to send, with impact limited to Telegram selected replies.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Mantis supplied before/after real Telegram Desktop and Bot API evidence for both direct and durable paths; the local prepared previews also show the selected-reply flow.
  • proof: sufficient: Contributor real behavior proof is sufficient. Mantis supplied before/after real Telegram Desktop and Bot API evidence for both direct and durable paths; the local prepared previews also show the selected-reply flow.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change affects visible Telegram selected-reply targeting, and the required Telegram Desktop proof has been supplied.

Evidence

What I checked:

  • Current-main root cause: Current main uses the shared string reader with its default trimming behavior for direct Telegram sends; the reader defaults trim to true and applies raw.trim(). (extensions/telegram/src/action-runtime.ts:676, 1fdd10bf6aa5)
  • Durable-path sibling: Current main independently applies the same default-trimming reader before storing Telegram channel data for durable presentation delivery. (extensions/telegram/src/channel-actions.ts:87, 1fdd10bf6aa5)
  • Sender invariant retained: The downstream sender still rejects whitespace-only quotes using a trim-only presence check while retaining nonblank quote bytes unchanged. (extensions/telegram/src/reply-parameters.ts:75, 1fdd10bf6aa5)
  • After-fix behavior proof: The attached Mantis run exercised both changed paths against a repeated padded substring; its candidate sent the exact quote bytes, received Telegram HTTP 200 responses, and showed both replies in Telegram Desktop. (c82bd5f7074c)
  • History limitation and routing: Blame attributes the changed lines to the shallow PR snapshot; deeper local history is grafted and GitHub history lookup was unavailable, so earlier feature ownership cannot be established confidently. (extensions/telegram/src/action-runtime.ts:676, df50e071f912)

Likely related people:

  • steipete: Available blame snapshot and the current focused commit connect this repository member to both affected ingress paths; deeper ownership history is unavailable locally. (role: recent area contributor; confidence: low; commits: df50e071f912; files: extensions/telegram/src/action-runtime.ts, extensions/telegram/src/channel-actions.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T11:07:43.070Z sha df50e07 :: needs real behavior proof before merge. :: none

@openclaw-mantis

openclaw-mantis Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Mantis Telegram proof — PASS

Summary: A real Telegram user sent a message containing two occurrences of 'selected passage', with the intended second occurrence surrounded by two leading and trailing spaces. Mocked model tool calls then sent selected-quote replies through both the direct Telegram action path and the durable rich-presentation payload path. Current main silently trimmed the requested quote to 'selected passage' in both paths. The candidate preserved ' selected passage ' byte-for-byte in both Bot API requests. Telegram accepted every request with HTTP 200 and Telegram Desktop displayed each reply against the intended source message.

  • Scenario: In a real Telegram forum topic, send the source text 'ANCHOR\nselected passage\n\n selected passage \nTAIL'. Drive OpenClaw through its model-visible exec/catalog message tool to reply to that source with quoteText=' selected passage '. Exercise once as an ordinary message action and once with a rich presentation so both changed quote-ingress owners are covered. Inspect Telegram Desktop, observer events, provider requests, and recorded sendMessage request bodies.
  • Trigger: clawsweeper_label
  • Run: https://github.com/openclaw/openclaw/actions/runs/32841392288
  • Artifact: https://github.com/openclaw/openclaw/actions/runs/32841392288/artifacts/9561078761
  • Baseline: pass at 34a1cfc69c96db6133dff04e8502c975697f406b — Expectation met in two completed baseline attempts. The ordinary action and durable presentation action both supplied quoteText=' selected passage ', but their recorded sendMessage bodies contained reply_parameters.quote='selected passage'. Telegram returned HTTP 200 and Desktop showed the resulting narrower selected-quote replies, demonstrating the silent wrong-selection behavior.
  • Candidate (PR merged onto main): pass at c82bd5f7074c00a273b6653d855e08013d39795d — Expectation met in the completed candidate lane. Both the ordinary action and durable presentation action produced sendMessage bodies with reply_parameters.quote=' selected passage ' exactly as supplied. Telegram returned HTTP 200 for both, observer events tied both bot replies to the source message, and Desktop displayed both replies.
  • Differential (trusted facts): The source message, selected quote bytes, mock tool intent, and Telegram destination were equivalent. The baseline changed the quote from two-space-padded text to its trimmed interior in both production paths; the candidate sent the exact padded substring in both. Successful Bot API responses and Desktop-visible replies rule out a synthetic-only result. This directly proves that the pull request fixes the reported whitespace-loss defect.
  • Overall: pass
Before — current main After — this PR
baseline previewGifCropped candidate previewGifCropped

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-visible/pr-129254/run-32841392288-1/index.json

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@steipete
steipete merged commit 474d785 into main Aug 25, 2026
152 checks passed
@steipete
steipete deleted the codex/qa-telegram-exact-quote-20260825 branch August 25, 2026 13:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant