[codex] Fix Telegram DM topic session routing#88421
Conversation
2270a0b to
c60dd29
Compare
|
Codex review: needs maintainer review before merge. Reviewed May 30, 2026, 6:40 PM ET / 22:40 UTC. Summary PR surface: Source +5, Tests +17. Total +22 across 2 files. Reproducibility: yes. The current main resolver and inbound session code show the mismatched outbound bare-topic suffix versus inbound chat-scoped suffix; I did not execute tests because this review is read-only. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow route fix after maintainer acceptance of the one-time DM-topic session-key cutover; add a compatibility bridge only if old outbound-only session rows are considered a shipped data contract. Do we have a high-confidence way to reproduce the issue? Yes. The current main resolver and inbound session code show the mismatched outbound bare-topic suffix versus inbound chat-scoped suffix; I did not execute tests because this review is read-only. Is this the best way to solve the issue? Yes, with maintainer acceptance. The narrowest maintainable fix is to align Telegram's plugin-owned outbound route with inbound DM-topic session keys while re-normalizing delivery metadata to the numeric Telegram topic id. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 57c88dd46e2d. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +5, Tests +17. Total +22 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
|
@openclaw-mantis telegram-visible-proof requested for PR 88421 / issue 80212. Please use the Crabbox native Telegram Desktop proof path for the exact ClawSweeper proof shape:
Redact bot tokens and user identifiers as needed. Do not trigger ClawSweeper re-review. |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Real behavior proof attempt for the Telegram DM-topic path is currently blocked by the live QA credential, not by a local test failure. Behavior addressed: attempted proactive Telegram DM-topic send plus same-topic user reply routing for PR 88421 under isolated DM scope. Real environment tested: AWS Crabbox Exact steps or command run after this patch: started Evidence after fix: the gateway came up with the PR head and isolated DM scope, but Telegram capability probing returned Observed result after fix: no valid Telegram private DM topic could be created or opened with the current QA credential, so the requested real DM-topic roundtrip proof cannot be produced from this lease. The Crabbox credential and AWS box were released after the attempt. What was not tested: the requested successful proof shape, namely proactive DM-topic send, same-topic user reply into the same OpenClaw session, and successful outbound delivery into a Telegram private topic. That needs a topics-enabled SUT bot credential, or the owner of |
|
Proof status reminder for issue #80212 / PR #88421: The source regression and local route proof are in place, but the remaining requested proof is still the live/real-behavior Telegram DM-topic path:
Current blocker: the available Crabbox/Mantis Telegram proof path is not producing that artifact yet. A prior maintainer-triggered Mantis run reached Crabbox but failed because the harness could not open a comparable direct Telegram DM-topic view; local runner access is also blocked without the Convex Telegram QA credential env. We also intentionally did not use the reporter's VPS group/forum topics because group-topic proof would not cover the direct DM-topic issue shape. No re-review request intended from this comment. This is just a reminder/status note until the Telegram Crabbox credential/harness path is healthy or a maintainer provides equivalent redacted proof. |
Live Telegram DM-topic proof addendumRan a live proof on the user's OpenClaw VPS with a temporary PR-equivalent bundle patch, then restored the installed bundle from backup. Environment:
Proof flow:
{
"sessionKeyShape": "agent:main:telegram:direct:<chatId>:thread:<chatId>:40931",
"baseSessionKeyShape": "agent:main:telegram:direct:<chatId>",
"threadId": 40931,
"fromShape": "telegram:<chatId>:topic:40931",
"toShape": "telegram:<chatId>",
"chatType": "direct"
}
openclaw message send --channel telegram --target <chatId> --thread-id 40931 --message "oc-88421 proof proactive send from patched OpenClaw route..." --jsonResult: {
"action": "send",
"channel": "telegram",
"dryRun": false,
"handledBy": "plugin",
"messageId": "9465",
"payload": { "ok": true, "messageId": "9465" }
}Server log confirms delivery used the numeric topic id, not the scoped session token:
Server log confirms the reply landed back in the same scoped session: The bot's timeout/status response also delivered back into the same numeric topic id: Cleanup/restoration:
Residual note: the visible bot reply was a normal agent timeout, not a routing failure; it still proves the reply was processed in the scoped DM-topic session and delivered back to numeric |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
c60dd29 to
2492c08
Compare
2492c08 to
d904115
Compare
steipete
left a comment
There was a problem hiding this comment.
Maintainer review: approved for landing.
Verification reviewed before merge:
- PR head: d904115
- Live PR checks: CI/check lanes green; Real behavior proof green; OpenGrep green; CodeQL neutral/pass.
- Local maintainer review: source mismatch confirmed between outbound direct-topic session suffix and inbound DM-topic reply session suffix.
- Merge sanity: merge-tree against current origin/main has no conflicts; git diff --check on touched files passed.
Accepted risk: this intentionally cuts proactive Telegram DM-topic outbound sessions over from the old bare topic suffix to the inbound-compatible chat-scoped suffix. No compatibility bridge is needed because the old key shape was the reported bug, not a public contract.
Summary
This PR fixes Telegram proactive DM-topic session continuity for #80212.
chatId:threadIdthread suffix.174872rather than the scoped session token.Linked context
Closes #80212
Related #82164, #82200, #18974, #18993
Requested by maintainer coordination for
issue-80212.Real behavior proof
2026.5.27 (27ae826)on the user's VPSpolymarket-mc, usingAnt_clawd_botand a real private Telegram DM topic. Chat/user ids are redacted as<chatId>. A temporary PR-equivalent bundle patch was applied for the proof and restored afterward.oc-88421 proof start.openclaw message send --channel telegram --target <chatId> --thread-id 40931 --message "oc-88421 proof proactive send from patched OpenClaw route..." --json.oc-88421 proof reply.{ "sessionKeyShape": "agent:main:telegram:direct:<chatId>:thread:<chatId>:40931", "baseSessionKeyShape": "agent:main:telegram:direct:<chatId>", "threadId": 40931, "fromShape": "telegram:<chatId>:topic:40931", "toShape": "telegram:<chatId>", "chatType": "direct" }{ "action": "send", "channel": "telegram", "dryRun": false, "handledBy": "plugin", "messageId": "9465", "payload": { "ok": true, "messageId": "9465" } }Full proof comment: #88421 (comment)
agent:main:telegram:direct:<chatId>:thread:<chatId>:40931; the user reply was processed in that same scoped session; both the proactive message and the visible timeout response delivered with numericthreadId=40931, not the scopedchatId:threadIdtoken.Source-runtime proof
Local OpenClaw source runtime at
C:\oc-work\oc-80212also invoked the production Telegram plugin resolver directly with Node/tsx.node --import tsx -e "const { telegramPlugin } = await import('./extensions/telegram/src/channel.ts'); const route = await telegramPlugin.messaging?.resolveOutboundSessionRoute?.({ cfg: { session: { dmScope: 'per-account-channel-peer' } }, agentId: 'finance', accountId: 'finance', target: '104506878:topic:174872' }); console.log(JSON.stringify({ sessionKey: route?.sessionKey, baseSessionKey: route?.baseSessionKey, threadId: route?.threadId, from: route?.from, to: route?.to }, null, 2));"Output:
{ "sessionKey": "agent:finance:telegram:finance:direct:104506878:thread:104506878:174872", "baseSessionKey": "agent:finance:telegram:finance:direct:104506878", "threadId": 174872, "from": "telegram:104506878:topic:174872", "to": "telegram:104506878" }Tests and validation
Which commands did you run?
pnpm install --frozen-lockfilenode scripts/run-vitest.mjs extensions/telegram/src/session-route.test.tsnode scripts/run-vitest.mjs extensions/telegram/src/session-route.test.ts extensions/telegram/src/bot-message-context.dm-threads.test.ts src/infra/outbound/outbound-session.test.tsgit diff --check$env:PYTHONIOENCODING='utf-8'; python .agents\skills\autoreview\scripts\autoreview --mode localWhat regression coverage was added or updated?
financeaccount/session shape.What failed before this fix, if known?
agent:finance:telegram:finance:direct:104506878:thread:174872before this change.Risk checklist
Did user-visible behavior change? (
Yes/No)Yes. Telegram proactive DM-topic sessions now align with inbound replies.
Did config, environment, or migration behavior change? (
Yes/No)No.
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)No.
What is the highest-risk area?
Telegram direct-topic route metadata, especially separating session suffixes from numeric delivery topic ids.
How is that risk mitigated?
The source-runtime proof, live Telegram proof, and regression tests assert both the aligned session key and the preserved numeric delivery thread id.
Current review state
What is the next action?
Maintainer review and CI.
What is still waiting on author, maintainer, CI, or external proof?
Live Telegram proof has now been supplied in the PR body and proof comment. Awaiting maintainer/automation review and CI.
Which bot or reviewer comments were addressed?
Focused autoreview initially caught recovered current-session delivery metadata using scoped tokens; this patch was updated and the final autoreview was clean.