Skip to content

fix(telegram): ignore commands addressed to other bots - #118024

Merged
vincentkoc merged 1 commit into
mainfrom
fix/telegram-foreign-bot-commands
Aug 2, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/telegram-foreign-bot-commands

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where Telegram groups with optional mentions could send /command@other_bot into the OpenClaw agent as a normal user request.

Why This Change Was Made

Telegram's bot_command entity is now checked at the inbound body owner before command authorization, history, or agent dispatch. A leading command explicitly addressed to another bot is dropped, while commands for this bot and later command tokens remain unchanged.

This is the canonical runtime repair discovered during Beta 7 live QA. Beta-only QA adapter and scenario changes are intentionally excluded.

User Impact

OpenClaw no longer responds to Telegram commands intended for another bot in the same group.

Evidence

  • Before fix: focused regression returned inboundEventKind: "user_request" for /status@other_bot
  • After fix: node scripts/run-vitest.mjs extensions/telegram/src/bot-message-context.body.test.ts — 30 passed
  • grammY 1.45.1 contract inspected: command middleware rejects @other_bot targets before invoking the registered command handler
  • Targeted oxfmt and git diff --check passed
  • Fresh local autoreview: clean, correctness 0.99
  • Production LOC: +30/-0; tests: +45/-0
  • No config, protocol, or public API change

@vincentkoc vincentkoc self-assigned this Aug 2, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@vincentkoc
vincentkoc marked this pull request as ready for review August 2, 2026 15:25
@clawsweeper

clawsweeper Bot commented Aug 2, 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:

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 11:29 AM ET / 15:29 UTC.

ClawSweeper review

What this changes

Stops a Telegram group message whose leading command targets a different bot from being treated as an OpenClaw user request, while preserving commands targeting this bot.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for normal maintainer review. Current main has no foreign-bot command guard at the Telegram inbound-body boundary, and this branch adds a narrow early drop with focused regression coverage; its MEMBER authorship and maintainer label rule out automated cleanup.

Priority: P1
Reviewed head: 2cdee08e86045f2fe4c03c3c8840edad9c621742
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-boundary repair with focused regression coverage and no concrete patch defect found in read-only review.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; its body reports focused test evidence, while a live Telegram probe remains the useful final validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; its body reports focused test evidence, while a live Telegram probe remains the useful final validation.
Evidence reviewed 5 items Current main still lacks the drop: Current main extracts Telegram text entities and immediately continues into command authorization; it has no check that a leading bot_command is addressed to another bot.
Owner-boundary repair: The branch rejects a leading command addressed to a different bot before command authorization, group-history handling, context construction, or agent dispatch.
Focused regression coverage: The branch covers a mention-optional group command for another bot returning no inbound body and retains an own-bot leading command when a later token targets another bot.
Findings None None.
Security None None.

How this fits together

Telegram updates enter the Telegram plugin's message-context builder, which resolves message text, mention and command authorization, history, and eventual agent dispatch. This change inserts a foreign-command decision before those later stages so another bot's command produces an intentional no-op.

flowchart TD
  A[Telegram group update] --> B[Text and entity extraction]
  B --> C[Inbound body resolution]
  C --> D{Leading command targets this bot?}
  D -->|Another bot| E[Record inbound drop and stop]
  D -->|This bot or normal text| F[Authorization and mention policy]
  F --> G[Context, history, and agent dispatch]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned Telegram behavior change land after CI and a live mention-optional group proof confirm the intended drop semantics? Land after live group validation: Confirm /status@other_bot produces no OpenClaw reply while /status@this_bot remains accepted, then land when required checks pass.

Why: The change intentionally discards an inbound update, and the protected maintainer workflow requires a human to accept the final behavior and validation evidence.

Before merge

  • Resolve merge risk (P1) - A read-only dependency check could not inspect grammY 1.45.1 source, and no inspectable live Telegram transcript accompanies the branch; a short mention-optional group probe should confirm the entity behavior before landing.
  • Complete next step (P2) - A MEMBER-authored PR carrying the protected maintainer label needs a human to accept the intended inbound-drop behavior and final Telegram/CI evidence; no narrow automated repair is indicated.
Agent review details

Security

None.

PR surface

Source +30, Tests +45. Total +75 across 3 files.

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

Review metrics

None.

Mantis proof suggestion

A Telegram live transcript would directly verify both the suppressed foreign-target command and the preserved own-target command behavior. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live proof: verify that `/status@other_bot` in a mention-optional group produces no OpenClaw reply while `/status@this_bot` still reaches it.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the early inbound-body guard, complete normal CI, and record a redacted live Telegram group check showing a foreign targeted command is quiet while this bot's targeted command still reaches OpenClaw.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the early inbound-body guard, complete normal CI, and record a redacted live Telegram group check showing a foreign targeted command is quiet while this bot's targeted command still reaches OpenClaw.

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

Yes—current-main source shows a bot_command addressed to another bot has no foreign-target guard before the normal command and mention path, and the branch adds a focused regression case for the mention-optional group input. The read-only review did not execute the test or a live Telegram probe.

Is this the best way to solve the issue?

Yes—the guard belongs at the inbound-body owner before authorization, history, context construction, and dispatch, rather than compensating later in agent handling. The branch also preserves the existing own-bot command behavior in a sibling test.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The PR repairs a Telegram group workflow in which a command for another bot can be misrouted into OpenClaw's agent path.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; its body reports focused test evidence, while a live Telegram probe remains the useful final validation.
  • add mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change alters whether a Telegram command receives an OpenClaw response, which is directly demonstrable in a short group-chat proof.

Label justifications:

  • P1: The PR repairs a Telegram group workflow in which a command for another bot can be misrouted into OpenClaw's agent path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply; its body reports focused test evidence, while a live Telegram probe remains the useful final validation.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change alters whether a Telegram command receives an OpenClaw response, which is directly demonstrable in a short group-chat proof.

Evidence

What I checked:

Likely related people:

  • Shakker: Recent history shows Shakker's command-recovery work immediately preceding the current inbound-body split, making them a strong routing candidate for command-ingress semantics. (role: recent command-recovery contributor; confidence: medium; commits: e1b639947d01; files: extensions/telegram/src/bot-message-context.body.ts, extensions/telegram/src/bot/body-helpers.ts)
  • wangyan2026: Current-line history attributes the surrounding inbound-body boundary to wangyan2026's recent extraction, so they are relevant to its ownership and integration. (role: current inbound-body refactor author; confidence: medium; commits: 70394e190cf1; files: extensions/telegram/src/bot-message-context.body.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Capture a redacted live mention-optional Telegram group result for foreign-target and own-target commands.
  • Land only after the required CI run completes successfully.

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.

@vincentkoc

Copy link
Copy Markdown
Member Author

@openclaw-mantis telegram live proof: verify that /status@other_bot in a mention-optional group produces no OpenClaw reply while /status@this_bot still reaches it.

@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Live QA

Summary: Mantis ran the Telegram live QA lane with Convex-leased credentials, rendered a redacted transcript in a Crabbox desktop browser, and captured screenshot/video evidence for PR review.

Telegram live transcript

Rendered Telegram live transcript in a Crabbox desktop browser

Telegram motion preview

Animated Telegram live transcript capture

Motion-trimmed clips:

Full videos:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-live/pr-118024/run-30754728286-1/index.json

@vincentkoc
vincentkoc merged commit b84e14f into main Aug 2, 2026
314 of 326 checks passed
@vincentkoc
vincentkoc deleted the fix/telegram-foreign-bot-commands branch August 2, 2026 16:25
@vincentkoc

Copy link
Copy Markdown
Member 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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