Skip to content

fix(telegram): keep DM topic auto-rename user message UTF-16 safe#101781

Merged
steipete merged 2 commits into
openclaw:mainfrom
hugenshen:fix/telegram-utf16-dm-topic-rename
Jul 9, 2026
Merged

fix(telegram): keep DM topic auto-rename user message UTF-16 safe#101781
steipete merged 2 commits into
openclaw:mainfrom
hugenshen:fix/telegram-utf16-dm-topic-rename

Conversation

@hugenshen

@hugenshen hugenshen commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Telegram DM-topic auto-labeling caps the first user message at 500 UTF-16 code units before sending it to the label model. A raw slice(0, 500) can stop after the high surrogate of an astral character and make OpenClaw pass malformed text into topic-label generation.

Why This Change Was Made

The Telegram-owned boundary now uses the existing truncateUtf16Safe helper from openclaw/plugin-sdk/text-utility-runtime. The 500-unit cap, raw-body preference, first-turn condition, configuration resolution, fire-and-forget behavior, and Telegram topic edit remain unchanged.

User Impact

A long first message in a Telegram DM topic no longer acquires a surrogate half when an emoji crosses the auto-label input boundary. Short messages and messages not crossing an astral-character boundary remain unchanged.

Evidence

  • The production dispatchTelegramMessage regression places an emoji's high surrogate exactly at code-unit index 499 and asserts that generateTopicLabel receives the exact 499-character prefix.
  • Blacksmith Testbox run 28996475282: the full bot-message-dispatch.test.ts shard passed, 172/172.
  • git diff --check: passed.
  • Fresh structured autoreview: clean, no accepted/actionable findings; confidence 0.99.

Live proof status

The required real-user Telegram harness was attempted. It stopped before leasing a credential or creating a Crabbox because the configured Convex burner credential file was absent and no environment override was available. The current harness also exercises an ordinary burner user/group, not a Telegram Business DM-topic update, so it cannot directly force this owner branch. No personal account was used and no live-behavior claim is made.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 1:41 AM ET / 05:41 UTC.

Summary
The PR replaces the Telegram DM-topic auto-label raw 500-code-unit slice with truncateUtf16Safe and adds a surrogate-boundary dispatch regression test.

PR surface: Source +1, Tests +28. Total +29 across 2 files.

Reproducibility: yes. for source-level reproduction: current main raw-slices first-turn DM-topic label input at 500 UTF-16 code units, so a boundary emoji can leave a dangling surrogate. I did not establish a live Telegram topic reproduction in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup 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 redacted Telegram Desktop, Bot API, terminal/live output, or runtime logs showing a first DM-topic emoji-boundary auto-rename produces a valid title.
  • If that branch cannot be forced by the current harness, ask a maintainer to record an explicit proof override rationale after reviewing the Testbox regression.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body cites a Testbox regression run and explains that live Telegram proof was attempted but could not exercise the DM-topic owner branch, so after-fix real behavior proof is still missing. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
Mantis can try to capture the missing visible Telegram Desktop topic rename proof without editing code or changing the PR. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: reproduce a first DM topic message with an emoji crossing the 500 UTF-16 code-unit boundary and capture that auto-topic rename succeeds with a valid title.

Risk before merge

  • [P1] Real Telegram after-fix proof is still missing for a visible DM-topic auto-rename path; the PR body says the available live harness could not directly exercise this owner branch.

Maintainer options:

  1. Decide the mitigation before merge
    Land the helper replacement after redacted live Telegram proof, equivalent runtime logs, or an explicit maintainer proof override confirms the first-turn emoji-boundary DM-topic rename succeeds.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The patch does not need an automated code repair; the remaining blocker is proof sufficiency for a visible Telegram topic path.

Maintainer decision needed

  • Question: Should this Telegram topic fix wait for live or equivalent DM-topic proof, or should a maintainer explicitly override the proof gate based on the focused Testbox regression?
  • Rationale: The code path and test are strong, but the scoped Telegram policy requires real topic proof and the PR body says the attempted live harness cannot directly force this branch.
  • Likely owner: steipete — steipete authored the current head’s test-tightening commit and is also connected to the shared UTF-16 truncation helper pattern.
  • Options:
    • Require or supply real Telegram proof (recommended): Keep the PR open until redacted Telegram Desktop, Bot API output, runtime logs, or equivalent live proof covers the DM-topic auto-rename branch.
    • Apply proof override: A maintainer may explicitly override the proof gate if they accept the focused Testbox regression as enough for this narrow unreachable-in-harness branch.

Security
Cleared: The diff only changes a Telegram string truncation call site and adds a focused test, with no dependency, workflow, permission, secret, or code-execution surface.

Review details

Best possible solution:

Land the helper replacement after redacted live Telegram proof, equivalent runtime logs, or an explicit maintainer proof override confirms the first-turn emoji-boundary DM-topic rename succeeds.

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

Yes for source-level reproduction: current main raw-slices first-turn DM-topic label input at 500 UTF-16 code units, so a boundary emoji can leave a dangling surrogate. I did not establish a live Telegram topic reproduction in this read-only review.

Is this the best way to solve the issue?

Yes, pending proof. Reusing the shared truncateUtf16Safe helper at the Telegram-owned truncation point preserves the RawBody preference, first-turn condition, and 500-unit cap while fixing the malformed UTF-16 boundary.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a narrow Telegram topic-label text-correctness bugfix with source-level reproduction and limited runtime blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body cites a Testbox regression run and explains that live Telegram proof was attempted but could not exercise the DM-topic owner branch, so after-fix real behavior proof is still missing. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram DM-topic auto-renaming and can be demonstrated in a short Telegram Desktop or live bot proof if the DM-topic branch can be exercised.
Evidence reviewed

PR surface:

Source +1, Tests +28. Total +29 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 28 0 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 30 1 +29

What I checked:

Likely related people:

  • Lukavyi: Authored the Telegram DM-topic auto-rename feature and the follow-up that switched label input to RawBody with the 500-code-unit truncation. (role: introduced behavior; confidence: high; commits: 25fc6e201235, 72f160df65e0, 466debb75c0b; files: extensions/telegram/src/bot-message-dispatch.ts, src/auto-reply/reply/auto-topic-label.ts, src/auto-reply/reply/auto-topic-label-config.ts)
  • obviyus: Committed the effective DM auto-topic config follow-up and was the committer on the pre-squash auto-topic label commits. (role: feature follow-up contributor; confidence: high; commits: 25fc6e201235, 72f160df65e0, 67e2332c2fc2; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-message-context.ts, src/auto-reply/reply/auto-topic-label.ts)
  • steipete: Authored the original shared invalid-UTF-16 truncation fix pattern and authored the latest PR test-tightening commit. (role: adjacent helper contributor; confidence: medium; commits: 63f5fa47deb6, ccaaee37d8d8; files: src/utils.ts, packages/normalization-core/src/utf16-slice.ts, extensions/telegram/src/bot-message-dispatch.test.ts)
  • vincentkoc: Recent Telegram dispatch and plugin-SDK localization work touched the same dispatch file and helper surfaces. (role: recent area contributor; confidence: medium; commits: e311943700ae, fa2379dbc883; files: extensions/telegram/src/bot-message-dispatch.ts, src/plugin-sdk/text-utility-runtime.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.
Review history (7 earlier review cycles)
  • reviewed 2026-07-07T16:20:06.757Z sha 8242fbf :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T02:23:26.695Z sha 96c56bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T02:35:42.262Z sha 96c56bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T03:27:04.397Z sha 96c56bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T03:37:57.895Z sha 96c56bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T03:52:35.651Z sha 96c56bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-08T04:54:58.830Z sha f0649f7 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@hugenshen
hugenshen force-pushed the fix/telegram-utf16-dm-topic-rename branch from 8242fbf to 96c56bd Compare July 8, 2026 02:14
@hugenshen

Copy link
Copy Markdown
Contributor Author

Squashed to a single commit and rebased on latest main. Behavior proof is covered by colocated regression tests (no scripts/proof-*.mjs).

Test run

pnpm test extensions/telegram/src/bot-message-dispatch.test.ts -t 'truncates DM topic auto-rename' — 1 passed

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Add surrogate-boundary regression for auto-topic label input truncation.

Co-authored-by: Cursor <[email protected]>
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready review completed at exact head ccaaee37d8d80ccc90eba4bce7cf146d18ad753c.

What I verified:

  • The production path now uses the shared plugin-SDK truncateUtf16Safe helper only at the existing 500-code-unit DM-topic label-input boundary. First-turn gating, configuration resolution, raw-body preference, label generation, and Telegram topic editing are unchanged.
  • The regression places an emoji across the boundary and asserts the exact 499-character model input, so it proves the changed owner path rather than only testing the helper.
  • Blacksmith Testbox run 28996475282: full extensions/telegram/src/bot-message-dispatch.test.ts, 172/172 passed.
  • Exact-head CI run 28996601808: successful.
  • git diff --check: passed.
  • Fresh structured autoreview: clean; no accepted/actionable findings; confidence 0.99.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 101781: hosted exact-head gates passed.

Live-proof gap: I attempted the repository's real-user Telegram Crabbox harness. It stopped before leasing credentials or creating a box because the configured Convex burner credential file is absent. The current harness also creates an ordinary burner user/group and cannot force the Telegram Business DM-topic update branch. No personal account was used, and I am not claiming live behavior proof.

@steipete
steipete merged commit a3f00d3 into openclaw:main Jul 9, 2026
98 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 9, 2026
…enclaw#101781)

* fix(telegram): keep DM topic auto-rename user message UTF-16 safe

Add surrogate-boundary regression for auto-topic label input truncation.

Co-authored-by: Cursor <[email protected]>

* test(telegram): tighten topic label boundary proof

---------

Co-authored-by: NIO <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram 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. size: XS 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.

2 participants