Skip to content

feat(gateway): include bot identity in session_key for multi-bot Telegram setups #17068

@zoommbi

Description

@zoommbi

Problem

When running multiple Hermes profiles with separate Telegram bots that share the same Telegram user ID, the session_key collides across bots.

Current behavior:

  • Bot A (profile: musk) receives message from user
    → session_key = agent:main:telegram:dm:{user_id}
  • Bot B (profile: astock) receives message from same user
    → session_key = agent:main:telegram:dm:{user_id} (collision)

Since build_session_key() in gateway/session.py uses only chat_id for Telegram DMs (no bot identifier), the same Telegram user talking to two different bots on the same Hermes instance produces identical session_keys.

Expected behavior:
Each bot should have isolated session state even when talking to the same user. The session_key should include bot identity so that:

  • Bot A → agent:main:telegram:bot:{bot_token_hash}:dm:{user_id}
  • Bot B → agent:main:telegram:bot:{bot_token_hash}:dm:{user_id}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions