Skip to content

fix(telegram): silently skip empty-text sends - #88810

Merged
obviyus merged 2 commits into
openclaw:mainfrom
amittell:fix/empty-text-silent-skip
Aug 5, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
amittell:fix/empty-text-silent-skip

Conversation

@amittell

@amittell amittell commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #59725.

What Problem This Solves

Telegram now rejects rendered-empty text with 400: Bad Request: text must be non-empty. A visible answer followed by an invisible tail could therefore send the visible part, then report the whole reply as failed. Voice/media fallbacks could also claim text delivery when Telegram accepted nothing.

NO_REPLY is unchanged: it is still removed before channel delivery. This PR does not turn intentional suppression into an error.

Root Cause

Telegram delivery tracked empty-content rejection as an unconditional successful skip. That was correct only when another text or media part had actually landed. With zero accepted parts, callers received a false success and could record phantom delivery state.

Final keyboard and prompt-context facts were also reported before the true last accepted Telegram message was known.

Fix

  • Record the first empty-content rejection in the shared Telegram chunk tracker.
  • Succeed only when at least one chunk or media item actually landed; otherwise surface the original empty-content error.
  • Keep ordinary rejection precedence and existing partial-delivery identities.
  • Retry media without a caption when Telegram renders the caption empty.
  • Count voice/media fallback text only after Telegram returns a real message id.
  • Move a trailing inline keyboard to the actual last accepted message; keyboard-edit failure becomes partial delivery instead of silent success.
  • Defer durable media projection/reporting until the separate text outcome is known, so metadata describes what Telegram accepted.

Evidence

Exact head: c9f126cc7793587e1e78265c783a8962ba640ff6

  • Focused Vitest: 5 files, 342/342 tests passed.
  • Blacksmith Testbox run https://github.com/openclaw/openclaw/actions/runs/31006367049: repository guards, formatting, boundaries, dead-code scan, extension production tsgo, and extension test tsgo passed. Its final lint step found only two only-throw-error style violations; both were fixed, then exact-head targeted Oxlint passed.
  • Autoreview P0/P1: clean; no accepted/actionable findings.
  • Greybeard: no hot-path regression. New merge/allocation work is rejection-only; happy-path work remains constant per accepted message.
  • Production LOC: +514/-204, net +310. Growth establishes one factual delivery owner across text, voice, media, keyboard, receipt, and prompt projection paths. Test LOC: +394/-2, net +392.

Telegram real-behavior proof

telegram-e2e-userbot drove a dedicated real Telegram user in a DM through an ephemeral exact-head gateway and deterministic mock provider. Provider output was exactly 4,000 visible A characters plus two U+200B characters.

{
  "verdict": "pass",
  "head": "c9f126cc7793587e1e78265c783a8962ba640ff6",
  "driver": "telegram-e2e-userbot",
  "providerRequests": 1,
  "telegramApiEmptyRejections": 2,
  "sutEvents": { "typing": 2, "message": 1, "edit": 0, "delete": 0 },
  "visibleMessageLength": 4000,
  "phantomTailMessages": 0,
  "visibleErrorMessages": 0
}

The Bot API rejected the formatted invisible tail and its plain retry. The user saw one 4,000-character answer and no failure text.

ClawSweeper moves

  • Preserve the shared partial-delivery tracker in reply, default, and rich funnels.
  • Make all-empty delivery fail instead of returning phantom success.
  • Gate voice and caption fallback accounting on real Telegram message ids.
  • Preserve media-only success when separate empty text is rejected.
  • Report actual final keyboard and prompt-projection state.
  • Refresh exact-head tests, typechecks, lint, autoreview, and real Telegram proof.

Copilot AI review requested due to automatic review settings May 31, 2026 22:29
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 31, 2026
@clawsweeper

clawsweeper Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 9:04 AM ET / 13:04 UTC.

ClawSweeper review

What this changes

The PR classifies Telegram rendered-empty API rejections as skips and records delivery, keyboards, media captions, reply targets, and prompt context only for accepted messages.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still lacks this rendered-empty rejection handling, while the exact head implements the shared accepted-versus-skipped delivery boundary with no supported remaining correctness finding.

Priority: P1
Reviewed head: c9f126cc7793587e1e78265c783a8962ba640ff6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has strong real behavior proof and coherent shared delivery-state ownership, with normal exact-head CI gates still pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides exact-head live Telegram userbot output showing one visible message after two empty-tail Bot API rejections, with no phantom tail or visible failure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides exact-head live Telegram userbot output showing one visible message after two empty-tail Bot API rejections, with no phantom tail or visible failure.
Evidence reviewed 7 items Current-main gap: Current main treats every skippable rejected chunk alike; it has no rendered-empty classifier or all-silent-skip outcome, while the PR records the first silent rejection and surfaces it only when no chunk was accepted.
Shared owner boundary: The exact head applies the same tracker to durable plain and rich outbound sends, while pending accepted chunks finalize keyboard and prompt-context facts against the actual last accepted message.
Reply and media parity: Reply delivery advances reply and delivered state only for accepted chunks; voice and caption fallback paths avoid mirroring rejected text while preserving accepted media.
Findings None None.
Security None None.

How this fits together

Telegram reply and outbound funnels format agent output, send text or media through the Bot API, then record channel receipts and prompt context. This change ensures rejected empty chunks do not become phantom delivery state while accepted earlier chunks remain accurately finalized.

flowchart LR
  A[Agent reply or outbound text] --> B[Telegram formatting and chunking]
  B --> C[Reply or outbound delivery funnel]
  C --> D[Telegram Bot API]
  D --> E{Accepted, empty skip, or error}
  E -->|Accepted| F[Receipts and prompt context]
  E -->|Empty skip| G[No delivery state]
  E -->|Other error| H[Failure or partial delivery]
  F --> I[Visible Telegram message]
Loading

Before merge

  • Resolve merge risk (P1) - This +310-production-line delivery-state refactor changes message, keyboard, receipt, and prompt-context timing across reply and outbound funnels; required exact-head checks should complete before merge.
  • Complete next step (P2) - No repair lane is needed because the current head has no supported actionable finding; normal exact-head CI gating remains.
Agent review details

Security

None.

PR surface

Source +310, Tests +392. Total +702 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 514 204 +310
Tests 5 394 2 +392
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 908 206 +702

Review metrics

Metric Value Why it matters
Production versus test delta production +514/-204; tests +394/-2 The production growth is justified by consolidating accepted-message ownership across text, media, keyboard, receipt, and prompt-projection paths.

Root-cause cluster

Relationship: canonical
Canonical: #88810
Summary: This PR is the active canonical implementation for Bot API rendered-empty rejection accounting; earlier whitespace filtering and an unmerged predecessor only partially overlap.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the reviewed delivery-state change (recommended)
    Merge after exact-head required checks complete, using the supplied live Telegram proof and focused regressions as the behavior gate.

Technical review

Best possible solution:

Land the shared accepted-message accounting only after required exact-head checks complete, retaining the common tracker rather than adding downstream hook or transcript guards.

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

Yes: the exact-head live Telegram userbot run reproduces a visible 4,000-character message followed by rejected invisible tail sends, and the source-level regression covers the same path.

Is this the best way to solve the issue?

Yes: a shared tracker plus accepted-message bookkeeping repairs the producing delivery boundary; downstream hook or transcript guards would leave phantom state possible in sibling funnels.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides exact-head live Telegram userbot output showing one visible message after two empty-tail Bot API rejections, with no phantom tail or visible failure.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Rendered-empty Telegram replies can currently turn a visible answer into a reported failure or phantom delivery state.
  • merge-risk: 🚨 message-delivery: The PR changes whether rejected text chunks and captions count as channel deliveries.
  • merge-risk: 🚨 session-state: The PR changes reply-target consumption and prompt-context finalization after partial sends.
  • 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 (live_output): The PR body provides exact-head live Telegram userbot output showing one visible message after two empty-tail Bot API rejections, with no phantom tail or visible failure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head live Telegram userbot output showing one visible message after two empty-tail Bot API rejections, with no phantom tail or visible failure.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. This is a directly visible Telegram delivery change: users should see the accepted message without an invisible-tail failure.

Evidence

What I checked:

  • Current-main gap: Current main treats every skippable rejected chunk alike; it has no rendered-empty classifier or all-silent-skip outcome, while the PR records the first silent rejection and surfaces it only when no chunk was accepted. (extensions/telegram/src/chunk-delivery.ts:44, c9f126cc7793)
  • Shared owner boundary: The exact head applies the same tracker to durable plain and rich outbound sends, while pending accepted chunks finalize keyboard and prompt-context facts against the actual last accepted message. (extensions/telegram/src/send-message-text.ts:404, c9f126cc7793)
  • Reply and media parity: Reply delivery advances reply and delivered state only for accepted chunks; voice and caption fallback paths avoid mirroring rejected text while preserving accepted media. (extensions/telegram/src/bot/delivery.replies.ts:260, c9f126cc7793)
  • Regression coverage: The new exact-head test covers a visible 4,000-character message followed by two rendered-empty rejections, asserting keyboard retrofit and final prompt-context projection; adjacent tests cover all-empty failure. (extensions/telegram/src/send.test.ts:1853, c9f126cc7793)
  • Live behavior proof: The PR body’s exact-head Telegram userbot run reports two Bot API empty rejections, one visible 4,000-character message, no phantom tail, and no visible error message. (c9f126cc7793)
  • Current-main and release check: The PR head is not an ancestor of current main, and current main is not contained by latest release v2026.7.1-2; this remains unreleased active work rather than an obsolete fix. (c9f126cc7793)

Likely related people:

  • obviyus: Authored the two current-head commits that implement the accepted-versus-skipped delivery behavior. (role: recent implementation contributor; confidence: high; commits: 0cee344bf12f, c9f126cc7793; files: extensions/telegram/src/chunk-delivery.ts, extensions/telegram/src/send-message-text.ts, extensions/telegram/src/bot/delivery.replies.ts)
  • steipete: Current-main blame places the surrounding outbound text sender in this recent refactor commit; earlier history is unavailable locally beyond the sparse boundary. (role: recent current-source refactor author; confidence: medium; commits: 2b003f186dd8; files: extensions/telegram/src/send-message-text.ts)
  • hydro13: Merged Telegram PR fix(telegram): skip empty text replies instead of crashing with GrammyError 400 #56620 established the earlier pre-send whitespace filtering that partially overlaps this API-rejection path. (role: adjacent behavior contributor; confidence: medium; commits: 4d6c8edd7484; files: extensions/telegram/src/bot/delivery.replies.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 (27 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-30T14:31:39.909Z sha bb2e5ad6f8b0d34f2155588cdb992e19d7c5a8bb :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T16:59:30.041Z sha efe53f6a2821f6c05f88fb61d6ecca5d9e4bc3e9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T04:47:16.672Z sha efe53f6a2821f6c05f88fb61d6ecca5d9e4bc3e9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:34:13.910Z sha 3234b23d52a3f9ebedc4769777b21f425513d501 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T07:07:56.873Z sha 8e510e1818180e6922d55dc853dcb22a855a5a84 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T07:27:47.022Z sha 8e510e1818180e6922d55dc853dcb22a855a5a84 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T17:18:40.746Z sha 8e510e1818180e6922d55dc853dcb22a855a5a84 :: needs changes before merge. :: [P1] Preserve shared partial-delivery tracking
  • reviewed 2026-08-05T11:27:21.239Z sha a9b256c7fb926f6cc3b5c3cf48f83c94421f52f0 :: needs changes before merge. :: [P1] Only mark a voice fallback delivered after its text sends | [P2] Clear skipped caption text from media accounting

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 May 31, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 31, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jun 1, 2026
@amittell

amittell commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

ClawSweeper P1 findings on this PR addressed in 07dd75c81e:

P1.1 — Skipped-send accounting in the caller

extensions/telegram/src/bot/reply-threading.ts:41-78 — sendChunkedTelegramReplyText's sendChunk callback now returns Promise<number | undefined>; when the chunk reports no delivered message id (the wrapper resolved undefined), the loop continues before markReplyApplied and markDelivered. That keeps progress.hasReplied, progress.hasDelivered, and progress.deliveredCount untouched for skipped sends, so the downstream guards in deliverReplies (progress.deliveredCount > deliveredCountBeforeReply at extensions/telegram/src/bot/delivery.replies.ts:914,925) correctly suppress the transcriptMirror push, set message_sent.success=false, and pass messageId=undefined for skipped chunks.

extensions/telegram/src/bot/delivery.replies.ts:191-217,240-252,302-326 — the two sendChunk callbacks now return the message id from sendTelegramText, and the voice-fallback per-chunk loop in sendTelegramVoiceFallbackText gets the same guard so a skipped first chunk does not flip appliedReplyTo or stash a phantom firstDeliveredMessageId (which would have stranded the reply reference, quote text, and buttons on the next real chunk).

maybePinFirstDeliveredMessage at extensions/telegram/src/bot/delivery.replies.ts:593 already short-circuits when firstDeliveredMessageId is not a number, so the pin path is covered by the accounting fix automatically.

P1.2 — deliverReplies regression test

New file extensions/telegram/src/bot/delivery.skip-accounting.test.ts (3 tests). Drives deliverReplies (not sendTelegramText in isolation) with sendTelegramText mocked at the module boundary so the integrated accounting is observable:

  • treats every-chunk-skipped text reply as a no-op across hooks, mirror, and delivered flag — single-reply skip-only batch produces { delivered: false }, no transcriptMirror, and message_sent fires with success=false/messageId=undefined.
  • does not pin a phantom message when the only chunk silently skips — delivery.pin=true does not call pinChatMessage when nothing delivered.
  • counts only delivered chunks when a multi-reply batch mixes a real send and a skipped send — mixed delivered + skipped batch produces exactly one transcript mirror entry, one message_sent.success=true with the real message id, and one message_sent.success=false with no message id.

P1.3 — Real Telegram round-trip proof

Updated PR body adds a second ### Live Telegram round-trip proof (added in response to ClawSweeper review) section under the existing ## Real behavior proof. Driver script tsx-imports the source-tree sendTelegramText (no mocked Bot.api) and calls it through a real grammy Bot against the live @requestymcrequestfacebot Bot API. Captured live API responses confirm:

  • Telegram returns the empty-text 400 with the newer "text must be non-empty" wording for <i></i> (the widened EMPTY_TEXT_ERR_RE catches it).
  • Source-tree sendTelegramText silently resolves undefined for that payload instead of throwing.
  • Bare <br> family payloads are actually rejected by Telegram with a parse-error 400, not the empty-text 400, and the PR intentionally lets parse errors with no plain fallback throw (unchanged behavior).
  • &nbsp; payloads are accepted by Telegram and delivered normally with a real message id.
  • One well-formed payload still delivers (message id 10661), proving the happy path did not regress.

Local verification:

  • node scripts/run-vitest.mjs run extensions/telegram/src/bot — 6 files, 183 tests, all passing.
  • node scripts/run-oxlint-shards.mjs --only=extensions --threads=4 — clean.
  • pnpm build — green.

Branch: amittell:fix/empty-text-silent-skip at 07dd75c81e.

@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. labels Jun 1, 2026
@amittell
amittell force-pushed the fix/empty-text-silent-skip branch from 07dd75c to b2653e1 Compare June 1, 2026 22:33
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 1, 2026
@amittell amittell changed the title fix(telegram): silently skip empty-text and HTML-whitespace sends fix(telegram): silently skip empty-text sends Jun 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 1, 2026
@amittell
amittell force-pushed the fix/empty-text-silent-skip branch from b2653e1 to f066f09 Compare June 1, 2026 22:38
@amittell

amittell commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

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

@amittell

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (0d7c2f2d13d) and implemented the durable review's findings:

  • [P2] shared classifier: the empty-content wordings now live in one place — isTelegramEmptyContentError in extensions/telegram/src/rich-plain-fallback.ts (plain-lane "message text is empty" / "text must be non-empty" plus RICH_MESSAGE_CONTENT_REQUIRED). The reply funnel's local regex is gone.
  • [P1] funnel parity: the durable outbound funnel (send.ts sendTelegramTextChunks) now applies the same no-op recovery — a chunk Telegram rejects as empty content is skipped with a warn instead of failing the whole send, matching the reply funnel. The rich lane already no-opped via the content-required fallback plan.
  • Parity tests: classifier unit tests in rich-plain-fallback.test.ts, a durable-funnel skip test in send.test.ts, and the existing reply-funnel suite (all green locally: 103 + 174 tests, tsgo:extensions:test clean).

@amittell

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@amittell

Copy link
Copy Markdown
Contributor Author

Addressed the open P1 ("Preserve first-delivery metadata after an outbound skip") at head c089d2330c9, rebased onto main a29214a.

What changed (extensions/telegram/src/send-message-text.ts): createTelegramTextSender now commits delivered-chunk bookkeeping through a small delivery committer instead of eagerly per chunk. Each delivered chunk's reportDelivery + recordDeliveredPromptContext are buffered one step and flushed with finalPart=false when a later chunk delivers, finalPart=true at loop end, or flushed-without-final before rethrowing hard errors. The inline keyboard still rides the last attempted chunk (zero extra API calls in the normal case); when trailing chunks all skip as empty, finish() retrofits the keyboard onto the last delivered message via editMessageReplyMarkup, downgrading a failed retrofit to a warning with accurate telegramHasInlineKeyboard metadata. All three delivery sites (plain loop, rich loop, rich-to-plain fallback sub-loop) route through the committer, replacing the three duplicated bookkeeping blocks.

One scope note on the finding: reply anchoring in this funnel was not index-broken -- shouldIncludeReplyForChunk's only index dependence is the chunkCount === 1 case, unlike the reply funnel that needed hasDeliveredChunk. The real index-derived defects were the trailing-skip keyboard loss and the dangling final prompt-context part (resolveCompleteTelegramPromptContextProjectionIds requires the last part to carry finalPart=true), both fixed above.

Verification: 4 new regressions (trailing-skip retrofit, leading-skip part indexes, retrofit failure, rich-fallback final accounting) plus the existing hard-error flush test. send.test.ts 181/181; full extensions/telegram suite 180 files / 2960 passed; pnpm tsgo:extensions, oxlint, oxfmt clean.

Exact-head live proof (PR body's Real behavior proof section refreshed): live Bot API run at this head -- trailing chunk rejected 400: text must be non-empty, chunk 1 (message id 31071) delivered and then reported with telegramHasInlineKeyboard: true after the live editMessageReplyMarkup retrofit; ZWSP-only probe skips cleanly with messageId: ""; control send unchanged.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@amittell

Copy link
Copy Markdown
Contributor Author

CI note: checks-node-compact-large-2 failed on src/gateway/server-startup-log.test.ts:278 ("logs configured model thinking and fast mode defaults with the startup model") with a 120s per-test timeout. This PR's diff is entirely extensions/telegram/**, so the failing core-gateway test is unrelated to the change. The identical test timed out the same way on #89526's run minutes earlier (different diff, same shard agentic-control-plane-startup-core), and the file passes locally in 2.89s (14/14) on the same rebased base a29214acd8b. This looks like a fresh flake or environment-sensitive regression on current main's startup-log/model-catalog path rather than anything either PR introduces. Requesting a maintainer rerun: https://github.com/openclaw/openclaw/actions/runs/30396379094

@amittell

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 29, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@amittell

Copy link
Copy Markdown
Contributor Author

CI note: the last five runs on this branch each failed a different, unrelated test in the shared runner shards — server-startup-log (120s timeout), server.sessions.create worktree validation, playback-transcode pool saturation, a trufflehog image-pull timeout (exit 125 before any scanning), and now subagent-registry.announce-loop-guard — none in surfaces this PR touches, and each passes locally (e.g. announce-loop-guard 5/5, sessions.create 79/79). This looks like runner-load flakiness rather than anything in the diff; I'll retrigger once the shards settle instead of churning further.

@amittell

Copy link
Copy Markdown
Contributor Author

Follow-up with sharper evidence, since this branch has now had six red runs on six different shards.

The most recent failure is server.sessions.create.test.ts > sessions.create rejects worktrees for non-git agent workspaces, and the assertion shows it is environmental rather than diff-related:

- expected  { code: "INVALID_REQUEST", message: "agent workspace is not a git checkout" }
+ received  { code: "UNAVAILABLE",     message: "git worktree add failed: fatal: invalid reference: HEAD" }

The test's temp workspace is supposed to be a non-git directory; on the runner it resolves as a git repo with no commits, so the code takes the worktree-add path instead of the not-a-checkout path. It passes locally (79/79 in that file). Same test also failed an earlier run here; the other four failures were entirely different tests (server-startup-log 120s timeout, playback-transcode pool saturation, subagent-registry.announce-loop-guard, and a trufflehog image-pull timeout that exited 125 before scanning anything).

For context, main itself is currently red on a recent CI run with nine failing jobs (native-i18n, check-test-types, checks-fast-bundled-protocol, ios-build, checks-windows-node-test, and others), so this looks like a repo-wide CI instability window rather than anything in this PR. This diff only touches extensions/telegram/src/** and has no relationship to gateway sessions, worktrees, or the media/subagent paths that failed.

I am going to stop retriggering rather than burn more runner time; happy to re-run whenever CI settles or if a maintainer wants a fresh attempt.

@amittell

amittell commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Added the requested redacted exact-head live Telegram evidence to the PR body for efe53f6a2821f6c05f88fb61d6ecca5d9e4bc3e9. The live run demonstrates the trailing empty-content 400, successful inline-keyboard retrofit on the preceding delivered message, and prompt-context part 0 finalized with finalPart: true.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@amittell

amittell commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current openclaw/main and refreshed the PR body with redacted exact-head live Telegram evidence for 3234b23d52a3f9ebedc4769777b21f425513d501. The live run proves both empty-content retries are silently skipped, message 31491 remains the sole delivery, its inline keyboard is present, and prompt-context part 0 is finalized with finalPart: true.

Local verification on the same head: 231 focused tests passed; formatting, oxlint, and the Telegram TypeScript check passed; fresh full-diff review found no actionable findings.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@amittell

amittell commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and pushed exact head 8e510e1818180e6922d55dc853dcb22a855a5a84 after the prior upstream run failed on an unrelated plugin-SDK timeout and a canceled lint worker. Fresh review found two sensible gaps and both are fixed: locally empty rich chunks now retain visible plain fallback text in both reply and durable-send funnels, and structural rich failures classify before the broad entity matcher. Exact-head verification is green at 234 focused tests plus formatting, oxlint, and the Telegram extension TypeScript check; the final review found no actionable issues. The PR body now has canonical problem/evidence sections and distinguishes the prior live Telegram transcript from the final exact-head regressions. @clawsweeper re-review

@amittell

amittell commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Fresh CI on exact head 8e510e1818180e6922d55dc853dcb22a855a5a84 failed only src/gateway/server.sessions.create.test.ts > sessions.create rejects worktrees for non-git agent workspaces: https://github.com/openclaw/openclaw/actions/runs/30689025633/job/91340400374. The shard had 501 passing tests, and this PR changes only Telegram files. Exact-head Telegram verification is green at 234 focused tests plus formatting, oxlint, and extension TypeScript. The Actions rerun API rejects contributor access with Must have admin rights to Repository; could a maintainer please rerun the failed job?

@amittell

amittell commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Final-head live Telegram proof is now in the PR body for 8e510e1818180e6922d55dc853dcb22a855a5a84. The outbound-only run accepted message 31498, rejected both empty trailing sends, retained the inline keyboard, recorded exactly one 4,000-character delivery, and finalized prompt-context part 0. Credentials and chat identity are redacted.

Local verification on this head remains 234 focused tests plus formatting, oxlint, and the Telegram TypeScript check. The only exact-head CI failure is the unrelated gateway non-git-workspace test already identified above.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus

obviyus commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus

obviyus commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus

obviyus commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Landed via squash. Thanks @amittell!

  • Focused tests: 342 passed
  • Exact-head CI: 72 passed
  • Telegram E2E: one 4,000-character answer; no phantom tail or visible error
  • Source head: c9f126c
  • Merge commit: d85920c

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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

2 participants