Skip to content

fix(telegram): typed slash commands lose the replied-to message and its photo - #150028

Merged
obviyus merged 4 commits into
mainfrom
fix/telegram-native-commands-pipeline
Sep 16, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/telegram-native-commands-pipeline

Conversation

@obviyus

@obviyus obviyus commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

The broad diff removes the parallel native-command dispatcher and moves its coverage onto the shared message pipeline.

What Problem This Solves

Typed Telegram commands lose replied-to photos, quoted text, and conversation context. Caption commands already use the full message pipeline.

Why This Change Was Made

Native handlers keep /login and argument keyboards; other commands continue through message admission, reply-media hydration, and chat-session dispatch. The bespoke turn plan and duplicate delivery policy are removed. One ingress rule owns command authorization. The registered command map translates /export_session to /export-session without changing raw text. This state has one writer.

User Impact

Typed commands get normal message context. Command-only allowlists and owners retain access outside account-level sender lists; explicit chat and topic sender restrictions still apply. Disabled chats and topics stay disabled. Replies follow replyToMode and ordinary tool-progress policy. Session metadata is awaited before dispatch, and hook-suppressed final replies no longer trigger an empty-response fallback.

Evidence

Telegram Test Server, mock provider: hello, bare photo, then /btw what color is the image I replied to? replying to it. On 42951671d, the side-question request has no image; with this change and #150020 at abb9329291e, it contains input_image and the bot answers. The caption case also passes. Combined tests: 3,349 Telegram, 952 shared-state, and 121 side-question tests pass.

Live Telegram authorization check: a command-only sender receives /status and the /think keyboard. After an explicit chat restriction excludes them, status dispatch is dropped and /think returns only an authorization denial. Before the correction, both commands still executed. All 24 direct/group/topic, owner/command-list, included/excluded command tests pass.

node openclaw.mjs qa run --repo-root . --qa-profile smoke-ci --concurrency 1 --scenario telegram-command-prompt-context fails before the correction and passes after it: export acknowledgement and Telegram prompt context remain in the topic.

Compatibility

Native commands now use the chat session, not telegram:slash:<userId>. Menu applicability adds one plugin SDK export; the maintainer approved its exact +1 export and callable budgets. The unchanged menu consumer compiles against shipped 2026.9.4 and candidate package declarations; the new helper compiles against the candidate. No config, schema, or protocol change.

Consumers

Builtin commands use the shared pipeline. Login, keyboards, and plugin commands retain their native executors.

Invalidation

None: context is built per message.

Tests

Registered bot updates cover photo replies, captions, menu/login routing, command-name translation, command-only access, rejected senders, disabled topics, topic sessions, and progress. Removed dispatcher coverage is moved or retired with its deleted behavior.

A typed /command on Telegram was intercepted by the bot's native command
handler, which built its own bare inbound context from the prompt text. A
`/btw check this` sent as a reply to a photo lost the replied-to message,
its photo, quotes, forwards, topic context, and history, and ran in a
separate `telegram:slash` session instead of the chat session.

Route typed commands through the inbound message pipeline, the one owner of
Telegram message context. The native handler keeps only what the pipeline
cannot render, `/login` and argument menus, and otherwise continues to the
message middleware. The pipeline classifies a registered native command as a
native command turn so it keeps working with `commands.text: false`, applies
`commands.allowFrom` in the shared ingress gate, awaits session metadata
before dispatch, and no longer emits the empty-response fallback when a
reply hook cancels the final reply. The bespoke native turn plan, its slash
session, and its duplicate delivery policy are removed; native replies now
follow the ordinary reply-target and tool-progress policy.

The argument-menu applicability check moves into the command registry so
Telegram asks the same owner that renders menus.
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram size: XL maintainer Maintainer-authored PR labels Sep 16, 2026
@obviyus
obviyus marked this pull request as ready for review September 16, 2026 11:59
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 16, 2026, 12:41 PM ET / 16:41 UTC (Revision 5).

ClawSweeper review

What this changes

Routes typed Telegram commands through the shared message pipeline so they retain replied-to photos, quoted text, and chat context, while preserving native login and argument menus.

Merge readiness

⛔ Blocked before merge - 2 items remain

The prior scoped-authorization and command-name findings are resolved. This remains a useful, distinct Telegram fix; the merged side-question change does not replace it. No remaining blocking code defect was established.

Priority: P2
Reviewed head: 5fb1fb0c6fa9325fd0a08d5f04d7ea5d94e228e3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with reported live proof and resolved prior findings, pending a focused session-cutover compatibility check.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Reported Telegram Test Server runs exercise command reply-media hydration through provider input and bot output, while the updated live authorization observations show allowed command effects and rejection after scoped exclusion. The topic-context scenario also reports recovery; existing-session upgrade coverage remains a separate compatibility gap.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Reported Telegram Test Server runs exercise command reply-media hydration through provider input and bot output, while the updated live authorization observations show allowed command effects and rejection after scoped exclusion. The topic-context scenario also reports recovery; existing-session upgrade coverage remains a separate compatibility gap.
Evidence reviewed 9 items Prior authorization finding repaired: The exact latest commit restores explicit scoped allowlist enforcement in inbound admission, message-context construction, and native menu preparation. Its added registered-update matrix covers direct, group, and topic scopes for owners and command-list senders, both included and excluded.
Shared context and canonical command names: Registered native names are translated without rewriting RawBody. The shared context builder carries native command classification alongside reply-chain media and quoted context, replacing the deleted bare command dispatcher.
Current main still has the reported mechanism: Pinned main still constructs a separate native-command context from prompt text and uses telegram:slash sessions; that construction does not hydrate replied-to photos. The requested Telegram repair is therefore still necessary.
Findings None None.
Security None None.

How this fits together

Telegram’s inbound pipeline authorizes incoming updates, gathers reply context and media, and routes commands into an OpenClaw chat session. The reply dispatcher then applies Telegram delivery and topic policies.

flowchart TD
  A[Telegram command update] --> B[Native command handler]
  B --> C[Login or argument menu]
  B --> D[Shared message admission]
  D --> E[Reply context and media]
  E --> F[Chat session dispatch]
  F --> G[Telegram reply]
Loading

Before merge

  • Resolve merge risk (P1) - Native commands now share chat-session execution ownership instead of a separate slash session. The supplied evidence does not yet demonstrate continuity of pre-existing transcripts and saved session settings across that cutover; SDK consumer compilation does not cover this runtime transition.
  • Complete next step (P2) - Add redacted existing-session cutover evidence showing preserved transcript and saved model or thinking settings, or obtain explicit maintainer acceptance of that remaining compatibility uncertainty.
Agent review details

Security

None.

PR surface

Source -114, Tests -379, Docs 0, Other +2. Total -491 across 52 files.

View PR surface stats
Area Files Added Removed Net
Source 26 335 449 -114
Tests 24 1326 1705 -379
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 2 +2
Total 52 1666 2157 -491

Review metrics

Metric Value Why it matters
Public SDK contract 1 callable export added; 0 existing exports removed The shared menu-applicability predicate expands the public contract, with approval and consumer compilation reported in the PR body.

Merge-risk options

Maintainer options:

  1. Verify existing-session continuity (recommended)
    Add cutover evidence showing that a pre-existing Telegram session retains its transcript and saved model or thinking setting when typed commands use the shared pipeline.
  2. Explicitly accept the remaining cutover uncertainty
    A maintainer may accept the documented session transition based on source tracing and current live proof while acknowledging the missing existing-session run.

Technical review

Best possible solution:

Keep one Telegram context pipeline, with verified existing-session continuity and the documented additive SDK contract.

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

Yes, from source: replying to a photo with a typed native command reaches main’s bare command-context construction without reply-media hydration. The PR reports the corresponding before/after Telegram run; this review did not execute it.

Is this the best way to solve the issue?

Yes. Reusing the existing message-context owner removes the duplicate dispatcher and preserves native menus; the remaining validation concern is continuity across the session cutover.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a3017f76b531.

Labels

Label justifications:

  • P2: This fixes lost reply context in typed Telegram commands with a limited channel-specific blast radius.
  • merge-risk: 🚨 compatibility: The additive plugin API and retirement of separate slash-session execution warrant compatibility review, with existing-session cutover still un demonstrated.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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): Reported Telegram Test Server runs exercise command reply-media hydration through provider input and bot output, while the updated live authorization observations show allowed command effects and rejection after scoped exclusion. The topic-context scenario also reports recovery; existing-session upgrade coverage remains a separate compatibility gap.
  • proof: sufficient: Contributor real behavior proof is sufficient. Reported Telegram Test Server runs exercise command reply-media hydration through provider input and bot output, while the updated live authorization observations show allowed command effects and rejection after scoped exclusion. The topic-context scenario also reports recovery; existing-session upgrade coverage remains a separate compatibility gap.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Reply-photo context, native command responses, menus, and topic delivery are observable Telegram behavior.

Evidence

What I checked:

  • Prior authorization finding repaired: The exact latest commit restores explicit scoped allowlist enforcement in inbound admission, message-context construction, and native menu preparation. Its added registered-update matrix covers direct, group, and topic scopes for owners and command-list senders, both included and excluded. (extensions/telegram/src/bot-native-command-dispatch.ts:219, 5fb1fb0c6fa9)
  • Shared context and canonical command names: Registered native names are translated without rewriting RawBody. The shared context builder carries native command classification alongside reply-chain media and quoted context, replacing the deleted bare command dispatcher. (extensions/telegram/src/bot-message-context.session.ts:770, 5fb1fb0c6fa9)
  • Current main still has the reported mechanism: Pinned main still constructs a separate native-command context from prompt text and uses telegram:slash sessions; that construction does not hydrate replied-to photos. The requested Telegram repair is therefore still necessary. (extensions/telegram/src/bot-native-command-dispatch.ts:490, a3017f76b531)
  • Shipped session contract: The supplied latest release documents separate native Telegram slash sessions targeting the chat session. The branch intentionally changes that execution arrangement; existing-session cutover evidence remains relevant. Public docs: docs/tools/slash-commands.md. (docs/tools/slash-commands.md:585, 3a9d69db306c)
  • Reported live behavior and authorization proof: The complete supplied PR body reports Telegram Test Server photo-reply and caption runs with a mock provider, observing input_image and a bot answer on combined candidate abb9329291e. It separately reports an allowed command-only sender receiving /status and a /think keyboard, then status being dropped and only an authorization denial after scoped exclusion. These observations address the previous final-effect proof request. The captured context sourceRevision is 97dcdf7180c0a2e06f074ff5307f9cde5104ddc130338c66b6c6964eed4f6ac6; no linked media was supplied.
  • Related merged work is complementary: fix(btw): side questions ignore the image attached to the message #150020 merged at f597402. Its supplied body explicitly says it repairs downstream side-question image handling but does not repair Telegram native-command delivery. (f597402cb064)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record existing-session cutover evidence with preserved transcript and saved session settings.

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 (4 earlier review cycles)
  • reviewed 2026-09-16T12:14:48.537Z sha e23b80b :: blocked before merge. :: [P1] [P1] Preserve command-only authorization before message admission | [P2] [P2] Carry canonical command names through the pipeline handoff
  • reviewed 2026-09-16T14:35:00.362Z sha aef6364 :: needs real behavior proof before merge. :: [P1] Preserve explicit chat and topic allowlists for native commands
  • reviewed 2026-09-16T15:16:20.835Z sha 901f2cc :: needs real behavior proof before merge. :: [P1] [P1] Preserve explicit chat and topic allowlists for native commands
  • reviewed 2026-09-16T16:03:07.976Z sha 901f2cc :: needs real behavior proof before merge. :: [P1] [P1] Preserve explicit chat and topic allowlists for native commands

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 16, 2026
@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 150028
head: 901f2cc
run: 35113263338 attempt: 2
failed: checks-node-changed-extensions-bundle-21 job=104863489503 conclusion=failure
check: openclaw/ci-gate

obviyus added a commit that referenced this pull request Sep 16, 2026
…50020)

Most changed lines move existing tests into sibling files; all coverage remains.

## What Problem This Solves

`/btw` asks for an image already attached to its message or supplied as reply context.

## Why This Change Was Made

`/btw` now reuses the main turn's image resolver. Direct-provider requests and the bundled app-server side thread receive those images. Prompt assembly and shared test setup move into sibling files to avoid growing oversized files. This state has one writer; side questions still write no transcript.

## User Impact

Questions can use the attached image. Text-only CLI runtimes receive an omitted-image count. Other harness plugins may ignore images.

## Evidence

Telegram Test Server, mock provider: send hello, then a photo captioned `/btw what color is this image?`. On `42951671d`, the side-question request has text only. On the final combined candidate `abb9329291e`, it includes `input_image` and the bot answers. The reply-to-photo case also passes with #150028; this PR alone does not repair Telegram's native-command delivery. Combined tests: 121 side-question, 952 shared-state, and 3,349 Telegram tests pass.

## Compatibility

Optional `images` on `AgentHarnessSideQuestionParams`; no config, schema, or protocol change. The same external consumer compiles against shipped 2026.9.4 and candidate package declarations. Candidate image/no-image callbacks pass with matching candidate dependencies; this is not a release-installation test.

## Consumers

The direct request and bundled side-thread input consume images; the CLI prompt consumes the omitted count. Shared internal reply options own extracted file images.

## Invalidation

None: images are per-call data.

## Tests

Command, direct-request, harness, CLI, and app-server input regressions; existing tests moved without removing cases. An image already described by media understanding remains excluded; passing that description to `/btw` is a separate gap.

Co-authored-by: Ayaan Zaidi <[email protected]>
Keep command-only access outside account-level sender lists without
bypassing explicit chat or topic restrictions.
@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@obviyus
obviyus merged commit c853ee0 into main Sep 16, 2026
201 of 203 checks passed
@obviyus
obviyus deleted the fix/telegram-native-commands-pipeline branch September 16, 2026 17:01
@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Proof: On the Telegram Test Server, a typed /btw reply to a photo now carries that image into the side question. Command-only access still works, while explicit chat restrictions block command execution and menu delivery for excluded senders.

  • Bug: Typed commands used a separate context path that lost replied-to photos and other message context.
  • Fix: Typed commands use the shared message pipeline, with the existing scoped sender checks preserved.
Before After
Typed photo-reply command loses its image The side-question request includes the replied-to image
Native commands build separate message context Commands and captions share the message pipeline

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…enclaw#150020)

Most changed lines move existing tests into sibling files; all coverage remains.

## What Problem This Solves

`/btw` asks for an image already attached to its message or supplied as reply context.

## Why This Change Was Made

`/btw` now reuses the main turn's image resolver. Direct-provider requests and the bundled app-server side thread receive those images. Prompt assembly and shared test setup move into sibling files to avoid growing oversized files. This state has one writer; side questions still write no transcript.

## User Impact

Questions can use the attached image. Text-only CLI runtimes receive an omitted-image count. Other harness plugins may ignore images.

## Evidence

Telegram Test Server, mock provider: send hello, then a photo captioned `/btw what color is this image?`. On `c509330cb`, the side-question request has text only. On the final combined candidate `abb9329291e`, it includes `input_image` and the bot answers. The reply-to-photo case also passes with openclaw#150028; this PR alone does not repair Telegram's native-command delivery. Combined tests: 121 side-question, 952 shared-state, and 3,349 Telegram tests pass.

## Compatibility

Optional `images` on `AgentHarnessSideQuestionParams`; no config, schema, or protocol change. The same external consumer compiles against shipped 2026.9.4 and candidate package declarations. Candidate image/no-image callbacks pass with matching candidate dependencies; this is not a release-installation test.

## Consumers

The direct request and bundled side-thread input consume images; the CLI prompt consumes the omitted count. Shared internal reply options own extracted file images.

## Invalidation

None: images are per-call data.

## Tests

Command, direct-request, harness, CLI, and app-server input regressions; existing tests moved without removing cases. An image already described by media understanding remains excluded; passing that description to `/btw` is a separate gap.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…ts photo (openclaw#150028)

The broad diff removes the parallel native-command dispatcher and moves its coverage onto the shared message pipeline.

## What Problem This Solves

Typed Telegram commands lose replied-to photos, quoted text, and conversation context. Caption commands already use the full message pipeline.

## Why This Change Was Made

Native handlers keep `/login` and argument keyboards; other commands continue through message admission, reply-media hydration, and chat-session dispatch. The bespoke turn plan and duplicate delivery policy are removed. One ingress rule owns command authorization. The registered command map translates `/export_session` to `/export-session` without changing raw text. This state has one writer.

## User Impact

Typed commands get normal message context. Command-only allowlists and owners retain access outside account-level sender lists; explicit chat and topic sender restrictions still apply. Disabled chats and topics stay disabled. Replies follow `replyToMode` and ordinary tool-progress policy. Session metadata is awaited before dispatch, and hook-suppressed final replies no longer trigger an empty-response fallback.

## Evidence

Telegram Test Server, mock provider: hello, bare photo, then `/btw what color is the image I replied to?` replying to it. On `c509330cb`, the side-question request has no image; with this change and openclaw#150020 at `abb9329291e`, it contains `input_image` and the bot answers. The caption case also passes. Combined tests: 3,349 Telegram, 952 shared-state, and 121 side-question tests pass.

Live Telegram authorization check: a command-only sender receives `/status` and the `/think` keyboard. After an explicit chat restriction excludes them, status dispatch is dropped and `/think` returns only an authorization denial. Before the correction, both commands still executed. All 24 direct/group/topic, owner/command-list, included/excluded command tests pass.

`node openclaw.mjs qa run --repo-root . --qa-profile smoke-ci --concurrency 1 --scenario telegram-command-prompt-context` fails before the correction and passes after it: export acknowledgement and Telegram prompt context remain in the topic.

## Compatibility

Native commands now use the chat session, not `telegram:slash:<userId>`. Menu applicability adds one plugin SDK export; the maintainer approved its exact +1 export and callable budgets. The unchanged menu consumer compiles against shipped 2026.9.4 and candidate package declarations; the new helper compiles against the candidate. No config, schema, or protocol change.

## Consumers

Builtin commands use the shared pipeline. Login, keyboards, and plugin commands retain their native executors.

## Invalidation

None: context is built per message.

## Tests

Registered bot updates cover photo replies, captions, menu/login routing, command-name translation, command-only access, rejected senders, disabled topics, topic sessions, and progress. Removed dispatcher coverage is moved or retired with its deleted behavior.

Co-authored-by: Ayaan Zaidi <[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 docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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.

1 participant