Repository navigation
fix(telegram): typed slash commands lose the replied-to message and its photo - #150028
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 16, 2026, 12:41 PM ET / 16:41 UTC (Revision 5). ClawSweeper reviewWhat this changesRoutes 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 Review scores
Verification
How this fits togetherTelegram’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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -114, Tests -379, Docs 0, Other +2. Total -491 across 52 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
landpr-approve-unrelated-red |
…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.
|
Proof: On the Telegram Test Server, a typed
|
…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]>
…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]>
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
/loginand 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_sessionto/export-sessionwithout 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
replyToModeand 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. On42951671d, the side-question request has no image; with this change and #150020 atabb9329291e, it containsinput_imageand 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
/statusand the/thinkkeyboard. After an explicit chat restriction excludes them, status dispatch is dropped and/thinkreturns 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-contextfails 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.