Skip to content

fix(telegram): preserve forum topic routing#76920

Open
kesslerio wants to merge 17 commits into
openclaw:mainfrom
kesslerio:fix/telegram-topic-thread-fallback
Open

fix(telegram): preserve forum topic routing#76920
kesslerio wants to merge 17 commits into
openclaw:mainfrom
kesslerio:fix/telegram-topic-thread-fallback

Conversation

@kesslerio

@kesslerio kesslerio commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep Telegram thread-not-found fallback for General topic (message_thread_id=1), while failing closed for explicit non-General forum topic sends and direct/private topic sends.
  • Preserve Telegram topic routing for automatic async/heartbeat follow-ups by reusing stored topic thread IDs for plugin-owned group routes.
  • Seed explicit cron announce targets into isolated-session delivery context so completion and heartbeat notices stay on the configured topic instead of falling back to an agent default group.
  • Keep the effective diff focused on Telegram topic routing, cron delivery context, outbound target reconstruction, and the temporary current-main memory-core test-contract shim needed for CI.

Change Type

  • Bug fix
  • Refactor required for the fix
  • Feature
  • Documentation
  • Tests only

Scope

Telegram extension outbound delivery, shared heartbeat target resolution, isolated cron session delivery metadata, and one test-only memory-core mock compatibility update for the current subagent runtime contract.

Linked Issue / PR

Root Cause

The Telegram sender retried 400: message thread not found by removing message_thread_id too broadly. That is safe only for General-topic recovery, but unsafe for explicit non-General forum topics and direct/private topic sends because Telegram can then deliver into the wrong root context.

A separate async path could reconstruct heartbeat/completion delivery from incomplete session metadata. Topic-scoped Telegram sessions and explicit cron announce jobs could lose the thread id before later automatic notices were sent.

Regression Test Plan

  • Explicit forum topic text/media/sticker/poll sends reject after the first thread-not-found error and do not retry threadless.
  • Topic-qualified recipient strings such as telegram:group:<id>:topic:<thread> fail closed.
  • Direct/private and resolved username DM sends with explicit thread ids reject after the first thread-not-found error and do not retry threadless.
  • Draft stream preview/materialize sends fail closed for non-General forum topics and keep the existing stricter DM-preview behavior.
  • Heartbeat target resolution preserves stored thread IDs for plugin-owned group routes when only deliveryContext or origin.chatType carries the topic context.
  • Explicit Telegram cron announce targets persist session delivery context with the resolved chat id and topic thread id.

Real behavior proof

  • Behavior or issue addressed: Telegram topic sends must not silently retry without message_thread_id after Telegram reports message thread not found; async heartbeat/completion delivery must preserve the intended topic route instead of falling back to a group/default route.

  • Real environment tested: Disposable OpenClaw staging gateway on NixOS Linux, PR worktree /tmp/openclaw-pr76920-merge, head f515e5d36ac1166b955838c21489390dbfd9dbe2, using @kesslerClawBot in a real Telegram forum group (-1003908474243). The staging gateway was started from this PR head, and the proof script used the PR's built Telegram runtime, sendMessageTelegram from dist/extensions/telegram/runtime-api.js.

  • Exact steps or command run after this patch: Started the disposable gateway with OPENCLAW_CONFIG_PATH=/home/art/.local/state/openclaw-staging/disposable/openclaw.json and OPENCLAW_STATE_DIR=/home/art/.local/state/openclaw-staging/disposable/state, then ran a redacted proof script from /tmp/openclaw-pr76920-merge that exercised: root chat-scoped send to -1003908474243, explicit General topic -1003908474243:topic:1, invalid explicit non-General topic -1003908474243:topic:999999, and valid explicit non-General topic -1003908474243:topic:16.

  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): Copied live output from the staging gateway/proof run. Full PR comment: fix(telegram): preserve forum topic routing #76920 (comment)

    Key copied output:

    head=f515e5d36ac1166b955838c21489390dbfd9dbe2
    chat=-1003908474243
    generalTopic=1
    [telegram] outbound send ok accountId=default chatId=-1003908474243 messageId=14 operation=sendMessage deliveryKind=text chunkCount=1
    rootSend=ok messageId=14 chatId=-1003908474243
    [telegram] outbound send ok accountId=default chatId=-1003908474243 messageId=15 operation=sendMessage deliveryKind=text chunkCount=1
    generalTopicSend=ok messageId=15 chatId=-1003908474243 topic=1
    [telegram] message failed: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)
    invalidTopicSend=failed_closed topic=999999
    invalidTopicCheck=no_threadless_retry_observed
    
    nonGeneralTopicProof=head=f515e5d36ac1166b955838c21489390dbfd9dbe2
    nonGeneralTopic=16
    [telegram] outbound send ok accountId=default chatId=-1003908474243 messageId=17 operation=sendMessage deliveryKind=text threadId=16 chunkCount=1
    nonGeneralTopicSend=ok messageId=17 chatId=-1003908474243 topic=16
    
  • Observed result after fix: Root chat-scoped send succeeded without a topic/thread id; General topic delivery succeeded and remained chat-scoped; an invalid explicit non-General forum topic failed closed and did not retry threadless; a valid explicit non-General forum topic sent with threadId=16, proving delivery stayed in the requested forum topic.

  • What was not tested: I did not run a full live cron or heartbeat follow-up through the gateway in this proof pass. Existing focused tests still cover cron session delivery context and heartbeat topic-route reconstruction.

  • Proof limitations or environment constraints: The live proof covers the real Telegram transport and topic send path. Cron/heartbeat route reconstruction remains covered by focused regression tests rather than a scheduled end-to-end cron/heartbeat run.

  • Before evidence (optional but encouraged): ClawSweeper's current-main/source review for this PR identifies the pre-patch failure mode: explicit Telegram topic sends could retry threadless after message thread not found, and async follow-up routing could lose topic context. The after-fix proof above shows the explicit send path no longer retries threadless for an invalid non-General topic.

Verification

Current head 75acdc52684b07c8355966394f5ad5347a713e0a was refreshed against latest origin/main, trimmed back to the intended nine-file effective diff, and pushed after the commands above passed locally.

Security Impact

Reduces cross-topic message leakage in Telegram forum groups and private/direct topic contexts by failing closed when an explicit thread is stale or invalid, and by preserving topic context for automatic follow-up notices.

Compatibility / Migration

No config migration. Non-General forum topic and direct/private topic sends now surface the Telegram error instead of silently retrying threadless. Explicit cron announce routes now persist the intended delivery context for later automatic notices.

Risks

If an operator intentionally relied on stale explicit topic sends falling back to a root chat, those sends now fail. That behavior was the leakage bug this PR is meant to prevent.

The cron/session change is intentionally limited to resolved explicit delivery targets; bare delivery.mode: none jobs still avoid implicit last-target resolution.

AI Assistance

AI-assisted refresh, simplification, validation, and PR-body update.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M labels May 3, 2026
@clawsweeper

clawsweeper Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 27, 2026, 7:39 PM ET / 23:39 UTC.

Summary
The branch updates Telegram send and draft fallback policy plus cron/heartbeat delivery context so forum-topic routes keep thread IDs while unsafe threadless retries fail closed, with focused regression tests.

PR surface: Source +216, Tests +97. Total +313 across 8 files.

Reproducibility: yes. Source inspection and the PR's base-fails/head-passes test proof identify the threadless-fallback boundary, and the live Telegram proof exercises invalid and valid forum-topic sends on the PR head.

Review metrics: 2 noteworthy metrics.

  • Fallback policy change: 1 Telegram threadless fallback narrowed. Explicit non-General forum and direct topic sends now surface Telegram errors instead of retrying threadless, so maintainers should notice the upgrade behavior before merge.
  • Session route persistence: 1 cron pre-run session write added. Explicit cron announce targets now persist delivery context that later automatic notices can reuse.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none

Mantis proof suggestion
A native Telegram Desktop recording would materially help reviewers see that valid topic sends stay in-topic and invalid explicit topics do not post to General/root. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

telegram desktop proof: verify a valid non-General topic send lands in the requested topic and an invalid explicit topic does not post to General/root.

Risk before merge

  • Existing operators who relied on stale explicit non-General forum or direct-topic sends falling back to a root chat will now see a Telegram error instead; this is intentional but compatibility-visible.
  • The cron and heartbeat changes deliberately preserve stored topic routes for automatic notices, which can change where existing follow-up messages appear when sessions already carry topic metadata.
  • Live proof covers the transport-sensitive Telegram send fallback path, while cron and heartbeat route reconstruction remain proven by focused tests rather than a full live scheduled cron/heartbeat run.

Maintainer options:

  1. Accept fail-closed topic routing (recommended)
    Merge after a maintainer confirms stale explicit non-General and direct topic sends should error instead of retrying into the wrong chat surface.
  2. Ask for full scheduled-flow proof
    Pause for a live cron or heartbeat run if maintainers want end-to-end proof that automatic notices keep the configured topic thread ID.
  3. Redesign for legacy fallback
    If maintainers want root-chat fallback to remain available for existing setups, pause this PR and redesign the stricter behavior as an explicit opt-in mode.

Next step before merge
No narrow automated repair is identified; the remaining action is maintainer review of the compatibility, session-state, and message-delivery behavior before merge.

Security
Cleared: No supply-chain or security-boundary regression was found; the patch reduces cross-topic message leakage by failing closed on unsafe Telegram topic fallback.

Review details

Best possible solution:

Land the focused routing fix after maintainer acceptance of the fail-closed compatibility behavior and automatic-notice route preservation semantics.

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

Yes. Source inspection and the PR's base-fails/head-passes test proof identify the threadless-fallback boundary, and the live Telegram proof exercises invalid and valid forum-topic sends on the PR head.

Is this the best way to solve the issue?

Yes, pending maintainer acceptance. Centralizing the fallback predicate in Telegram send/draft paths and seeding explicit cron delivery context is a maintainable fix for the observed routing bug, with the main tradeoff being intentional fail-closed compatibility behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against da279041aba2.

Label changes

Label justifications:

  • P2: This is a normal-priority Telegram routing bug fix with real message-delivery impact but limited blast radius.
  • merge-risk: 🚨 compatibility: Merging changes stale explicit topic sends from threadless fallback behavior to surfaced Telegram errors.
  • merge-risk: 🚨 session-state: The PR writes explicit cron delivery context into session state for later automatic routing.
  • merge-risk: 🚨 message-delivery: The PR changes which Telegram topic/root surface receives sends, cron completions, and heartbeat follow-ups.
  • 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 includes copied live output from a disposable gateway using a real Telegram forum group on head f515e5d, showing valid topic delivery and invalid-topic fail-closed behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes copied live output from a disposable gateway using a real Telegram forum group on head f515e5d, showing valid topic delivery and invalid-topic fail-closed behavior.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram forum-topic delivery behavior that can be demonstrated in a short Telegram Desktop proof.
Evidence reviewed

PR surface:

Source +216, Tests +97. Total +313 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 297 81 +216
Tests 3 97 0 +97
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 394 81 +313

What I checked:

  • Root AGENTS.md policy read: Root AGENTS.md was read fully and applied; it treats plugin APIs, auth/session state, fallback behavior, and message delivery changes as compatibility/upgrade-sensitive review surfaces. (AGENTS.md:17, da279041aba2)
  • Scoped Telegram maintainer note: The Telegram maintainer note says failed topic sends should not be silently retried without topic metadata because wrong-surface success is worse than a loud Telegram error, which supports the PR's fail-closed direction. (.agents/maintainer-notes/telegram.md:18, da279041aba2)
  • PR merge diff scope: The synthetic merge diff against its merge parent is limited to Telegram helpers, draft/send runtime, cron run delivery context, outbound heartbeat target resolution, and focused tests: 8 files, +394/-81. (2a994fea20c3)
  • Telegram fail-closed implementation: The PR adds a shared threadless-fallback gate and only retries after message thread not found when fallback is explicitly allowed for the resolved target/thread. (extensions/telegram/src/send.ts:609, f515e5d36ac1)
  • Cron delivery context implementation: The PR seeds explicit resolved cron announce routes into the cron session entry before persistence, including channel, target, account, thread, and inferred group/direct chat type. (src/cron/isolated-agent/run.ts:752, f515e5d36ac1)
  • Regression coverage: The PR adds focused draft, cron session-store, and heartbeat route-thread tests for non-General fail-closed behavior and topic-route preservation. (src/infra/outbound/targets.test.ts:1000, f515e5d36ac1)

Likely related people:

  • steipete: Heavy recent history across Telegram send/runtime and outbound/cron routing files, including release and refactor work around these surfaces. (role: recent area contributor; confidence: high; commits: 10ad3aa16068, 9e2a1e12fdbb, e8c7481fd25e; files: extensions/telegram/src/send.ts, src/infra/outbound/targets.ts, src/cron/isolated-agent/run.ts)
  • vincentkoc: Recent cron isolated-run and delivery helper history touches the same session/delivery context paths this PR changes. (role: cron delivery area contributor; confidence: medium; commits: 28787985c4eb, a81dc153c61b, ef1346e50339; files: src/cron/isolated-agent/run.ts, src/infra/outbound/targets.ts)
  • Mariano: Introduced the recent isolated heartbeat topic-routing preservation work that this PR extends in outbound heartbeat target resolution. (role: adjacent feature owner; confidence: medium; commits: b42c9996337a; files: src/infra/outbound/targets.ts, src/infra/outbound/targets.test.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.

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 5, 2026
@kesslerio kesslerio changed the title fix(telegram): fail closed on stale forum threads fix(telegram): preserve forum topic routing May 5, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

Follow-up pushed in d40225f83e.

Addressed the prior review items:

  • Added cfg: TELEGRAM_TEST_CFG to the new Telegram send/sticker/poll tests and removed stale previewTransport test options that no longer exist in the draft stream API.
  • Added a CHANGELOG.md entry.
  • Extended the fix beyond thread-not-found retry: explicit cron announce topic routes are now persisted into isolated-session delivery context, and heartbeat target reconstruction preserves stored topic thread IDs for plugin-owned group routes when the session only has deliveryContext or origin.chatType.

Verification run locally:

  • pnpm test src/infra/outbound/targets.test.ts src/cron/isolated-agent.direct-delivery-core-channels.test.ts extensions/telegram/src/send.test.ts extensions/telegram/src/draft-stream.test.ts
  • pnpm test src/infra/heartbeat-runner.ghost-reminder.test.ts src/cron/isolated-agent/session.test.ts src/cron/isolated-agent.delivery-awareness.test.ts src/cron/isolated-agent/delivery-target.test.ts
  • pnpm test extensions/telegram/src/send.test.ts extensions/telegram/src/draft-stream.test.ts
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md extensions/telegram/src/send.test.ts extensions/telegram/src/draft-stream.test.ts src/cron/isolated-agent.direct-delivery-core-channels.test.ts src/cron/isolated-agent.test-setup.ts src/cron/isolated-agent/run.ts src/infra/outbound/targets.test.ts src/infra/outbound/targets.ts
  • git diff --check
  • pnpm check:changed

@hclsys

This comment was marked as low quality.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Rebased and refreshed this PR on current main.

Current head: 54b7b0d1f842
Base tested: origin/main 3f590b48280e
OpenClaw package version tested: 2026.5.12-beta.1
Node/pnpm: v22.21.1 / 11.1.0

Updates in this refresh:

  • Resolved the rebase conflicts against current main.
  • Kept the original fail-closed behavior for explicit non-General Telegram forum topics.
  • Preserved the cron/heartbeat topic-route work from d40225f83e.
  • Ran a simplification pass and collapsed the threadless fallback policy into the shared Telegram helper, while keeping normal send and draft-preview DM behavior distinct.
  • Updated the PR body with tested versions, base/head SHAs, and the remaining live-proof residual.

Local verification:

  • pnpm test extensions/telegram/src/send.test.ts extensions/telegram/src/draft-stream.test.ts
  • pnpm test src/infra/outbound/targets.test.ts src/cron/isolated-agent.direct-delivery-core-channels.test.ts
  • pnpm test src/infra/heartbeat-runner.ghost-reminder.test.ts src/cron/isolated-agent/session.test.ts src/cron/isolated-agent.delivery-awareness.test.ts src/cron/isolated-agent/delivery-target.test.ts
  • pnpm check:changed
  • git diff --check
  • codex review --base origin/main

GitHub check status after push: mergeable, 88 checks passing, 20 skipped, 0 pending. The only failed check is still Real behavior proof, which is expected from the existing label/gate because I cannot provide after-fix live Telegram forum proof from this checkout. This needs maintainer override or a live Telegram bot/forum verification run.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Test-based reproduction proof

This is automated reproduction evidence for the threadless-fallback boundary in this PR. It is not a live Telegram forum smoke, so it should not be treated as replacing the remaining Real behavior proof gate unless maintainers accept test proof for that gate.

Base reproduces the bug boundary

Base: origin/main at 3f590b48280e

I added a temporary failing regression test to a clean base worktree:

pnpm test extensions/telegram/src/draft-stream.test.ts -- -t "reproduction: does not retry forum message preview sends without thread when thread is not found"

Result: failed as expected. Base retries a forum/topic preview send without message_thread_id after Telegram returns 400: Bad Request: message thread not found.

Key failure:

AssertionError: expected "vi.fn()" to be called 1 times, but got 2 times
extensions/telegram/src/draft-stream.test.ts:199:29

That proves the pre-fix behavior still has a threadless retry path for explicit forum sends.

PR head passes the fixed behavior

Head: 54b7b0d1f842

The same behavior is covered by the committed PR test:

pnpm test extensions/telegram/src/draft-stream.test.ts -- -t "does not retry forum message preview sends without thread when thread is not found"

Result:

Test Files  1 passed (1)
Tests  1 passed | 32 skipped (33)
[test] passed 1 Vitest shard

So the current PR head proves base-fails/head-passes for the explicit forum send retry case: when a forum/topic send has a message_thread_id, this PR now fails closed instead of retrying into the group root.

Residual: I still have not run a live Telegram forum bot smoke against this PR head. The local tests prove the fallback bug boundary; they do not prove end-to-end production Telegram delivery into a real forum topic.

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L proof: supplied External PR includes structured after-fix real behavior proof. and removed size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 13, 2026
@kesslerio kesslerio force-pushed the fix/telegram-topic-thread-fallback branch from 7fe0c05 to bee6adf Compare May 13, 2026 17:55
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix gateway Gateway runtime labels May 13, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased this branch onto current upstream/main and addressed the P2 finding plus current-main CI guardrail failures:

  • Direct/private Telegram topic sends now fail closed on message thread not found; no threadless retry for DM/direct sends.
  • PR body has the required Real Behavior Proof fields and current tested versions/head SHA.
  • Patched the inherited lint/type/contract/OpenGrep failures that showed up after rebase (src/media/fetch.ts, plugin runtime config scope, Matrix test runtime boundary, and the sessions-patch lint cleanup).

Local checks run after the update:

pnpm check:test-types
pnpm lint --threads=8
pnpm test extensions/telegram/src/send.test.ts extensions/telegram/src/draft-stream.test.ts src/infra/outbound/targets.test.ts src/cron/isolated-agent.direct-delivery-core-channels.test.ts src/infra/heartbeat-runner.ghost-reminder.test.ts src/cron/isolated-agent/session.test.ts src/cron/isolated-agent.delivery-awareness.test.ts src/cron/isolated-agent/delivery-target.test.ts
pnpm test src/plugins/contracts/deprecated-internal-config-api.test.ts src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts
pnpm test src/plugins/registry.runtime-config.test.ts src/media/fetch.test.ts extensions/matrix/src/matrix/subagent-hooks.test.ts

I could not run local OpenGrep because opengrep is not installed in this environment, but the reported direct Response.arrayBuffer() finding in src/media/fetch.ts is removed.

@clawsweeper

clawsweeper Bot commented May 13, 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.

Re-review progress:

@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. labels May 27, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

Added live Telegram Bot API proof to the PR body and linked a public redacted transcript:

https://gist.github.com/kesslerio/ed41189511d354a6e4fbe4470ec73bc8

What the proof exercises on PR branch head f515e5d36ac1166b955838c21489390dbfd9dbe2:

  • valid non-General staging topic send keeps message_thread_id=39783 and succeeds
  • invalid explicit non-General topic 987654321 fails with message thread not found after exactly one Bot API call, proving no threadless retry
  • General topic send omits message_thread_id and succeeds chat-scoped

The proof uses the branch's sendMessageTelegram path with a real Telegram Bot API wrapper so the changed fallback policy is exercised against real Telegram transport without starting a second poller. The staging bot token could not access the group, so I used the production bot token for direct send-only proof; no polling was started.

The remaining live limitation is cron/heartbeat full-gateway proof. Existing focused tests still cover cron delivery context and heartbeat route reconstruction, while this live proof covers the transport-sensitive send fallback behavior that was blocking the PR.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 27, 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.

Re-review progress:

@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 27, 2026
@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 May 27, 2026
@kesslerio

Copy link
Copy Markdown
Contributor Author

Live Telegram forum-topic proof, head f515e5d36ac1166b955838c21489390dbfd9dbe2

I reran the topic-routing proof against a disposable OpenClaw staging gateway using @kesslerClawBot in a real Telegram forum group.

Environment:

OpenClaw PR head: f515e5d36ac1166b955838c21489390dbfd9dbe2
Gateway worktree: /tmp/openclaw-pr76920-merge
Staging group: -1003908474243
#General topic: 1
Non-General proof topic: 16
Bot: @kesslerClawBot

Command path used the PR's built Telegram runtime, sendMessageTelegram from dist/extensions/telegram/runtime-api.js, with the staging bot token loaded from local env and redacted from output.

Observed transcript:

head=f515e5d36ac1166b955838c21489390dbfd9dbe2
chat=-1003908474243
generalTopic=1
marker=pr76920-proof-1779918566238
[telegram] outbound send ok accountId=default chatId=-1003908474243 messageId=14 operation=sendMessage deliveryKind=text chunkCount=1
rootSend=ok messageId=14 chatId=-1003908474243
[telegram] outbound send ok accountId=default chatId=-1003908474243 messageId=15 operation=sendMessage deliveryKind=text chunkCount=1
generalTopicSend=ok messageId=15 chatId=-1003908474243 topic=1
[telegram] message failed: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)
invalidTopicSend=failed_closed topic=999999
invalidTopicError=GrammyError: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)
invalidTopicCheck=no_threadless_retry_observed

nonGeneralTopicProof=head=f515e5d36ac1166b955838c21489390dbfd9dbe2
nonGeneralTopic=16
nonGeneralMarker=pr76920-proof-topic16-1779919775720
[telegram] outbound send ok accountId=default chatId=-1003908474243 messageId=17 operation=sendMessage deliveryKind=text threadId=16 chunkCount=1
nonGeneralTopicSend=ok messageId=17 chatId=-1003908474243 topic=16

What this proves:

  • Root chat-scoped send succeeded without a topic/thread id.
  • #General topic 1 send succeeded and remained chat-scoped, matching Telegram's General-topic fallback behavior.
  • Invalid explicit topic 999999 failed closed with message thread not found and did not retry threadless.
  • Valid explicit non-General topic 16 sent successfully with threadId=16, proving topic-scoped delivery stays in the requested forum topic.

@kesslerio

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 27, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels May 27, 2026
@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. P2 Normal backlog priority with limited blast radius. 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: M 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.

3 participants