Skip to content

fix(telegram): namespace slash SessionKey by agent#38680

Merged
obviyus merged 2 commits intoopenclaw:mainfrom
0xtangping:fix/issue-38648-telegram-slash-sessionkey
Mar 7, 2026
Merged

fix(telegram): namespace slash SessionKey by agent#38680
obviyus merged 2 commits intoopenclaw:mainfrom
0xtangping:fix/issue-38648-telegram-slash-sessionkey

Conversation

@0xtangping
Copy link
Copy Markdown

Summary

Telegram native slash commands were storing session metadata under a bare key (telegram:slash:<id>), which omitted the agent:<agentId>: namespace. This could collide with agent-scoped sessions and lead to duplicate delivery routing.

Changes

  • Prefix Telegram slash SessionKey with agent:${route.agentId}:... in native command context.
  • Tighten the session-meta unit test to assert the exact namespaced key format.

Testing

  • pnpm exec vitest run src/telegram/bot-native-commands.session-meta.test.ts --config vitest.channels.config.ts

Fixes #38648

@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram size: XS labels Mar 7, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a session key namespacing bug in the Telegram native slash command handler. The SessionKey used when recording inbound session metadata for slash commands was previously telegram:slash:<id> — missing the agent:<agentId>: prefix that the rest of the session key scheme requires. The fix adds this prefix (agent:${route.agentId}:telegram:slash:${senderId || chatId}), eliminating potential key collisions with agent-scoped conversational sessions. The accompanying test is tightened from a loose toBeDefined() to an exact string assertion, which is a good improvement.

Key changes:

  • src/telegram/bot-native-commands.ts: SessionKey for native slash command context now carries the full agent:<agentId>:telegram:slash:<id> namespace, consistent with how AccountId, agentId, and session store writes are already scoped.
  • src/telegram/bot-native-commands.session-meta.test.ts: Assertion upgraded from toBeDefined() to an exact match on "agent:main:telegram:slash:200".

Observation (no action required): Several other test files (abort.test.ts, commands.test.ts, get-reply.reset-hooks-fallback.test.ts, reply.triggers…e2e.test.ts, pi-embedded-runner.resolvesessionagentids.test.ts) still reference the legacy bare telegram:slash:<id> format. These tests construct their own payloads independently and test downstream behavior rather than key generation, so they are not functionally broken by this change. They are worth updating in a follow-up for consistency.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted fix that corrects a namespace omission with no side effects on other production paths.
  • The change is a single-line fix to a string template, the surrounding session metadata and dispatch code already used the correct agent-scoped values, the test improvement is precise and correct, and no downstream production code parses or hard-codes the old bare telegram:slash: key format.
  • No files require special attention.

Last reviewed commit: 2f556c7

@0xtangping 0xtangping force-pushed the fix/issue-38648-telegram-slash-sessionkey branch from 2f556c7 to 0e037e9 Compare March 7, 2026 09:28
@obviyus obviyus force-pushed the fix/issue-38648-telegram-slash-sessionkey branch from 0e037e9 to 17a527d Compare March 7, 2026 12:45
@obviyus obviyus merged commit bfc36cc into openclaw:main Mar 7, 2026
9 checks passed
@obviyus
Copy link
Copy Markdown
Contributor

obviyus commented Mar 7, 2026

Landed via temp rebase onto main.

  • Gate: pnpm check; pnpm build; pnpm exec vitest run src/telegram/bot-native-commands.session-meta.test.ts --config vitest.channels.config.ts
  • Land commit: 17a527d
  • Merge commit: bfc36cc

Thanks @0xtangping!

mcaxtr pushed a commit to mcaxtr/openclaw that referenced this pull request Mar 7, 2026
vincentkoc pushed a commit to BryanTegomoh/openclaw-fork that referenced this pull request Mar 8, 2026
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
@obviyus obviyus self-assigned this Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Telegram slash command handler writes bare session key (missing agent: prefix) causing duplicate message delivery

2 participants