hermes - 💡(How to fix) Fix feat(gateway): include bot identity in session_key for multi-bot Telegram setups [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#17068Fetched 2026-04-29 06:37:24
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4
RAW_BUFFERClick to expand / collapse

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}

extent analysis

TL;DR

Modify the build_session_key() function in gateway/session.py to include the bot identifier, such as the bot token hash, to prevent session key collisions across bots.

Guidance

  • Identify the build_session_key() function in gateway/session.py and verify that it only uses chat_id for Telegram DMs.
  • Consider modifying the function to include the bot token hash in the session key, as suggested in the expected behavior.
  • Review the code to ensure that the bot token hash is accessible and can be used to construct the session key.
  • Test the modified function with multiple bots and the same Telegram user to verify that session key collisions are resolved.

Example

def build_session_key(chat_id, bot_token):
    # Assuming bot_token_hash is a function that generates a hash from the bot token
    bot_token_hash = bot_token_hash(bot_token)
    return f"agent:main:telegram:bot:{bot_token_hash}:dm:{chat_id}"

Notes

The solution assumes that the bot token is available and can be used to generate a unique hash. The actual implementation may vary depending on the specific requirements and constraints of the system.

Recommendation

Apply workaround: Modify the build_session_key() function to include the bot identifier, as this will resolve the session key collision issue and provide isolated session state for each bot.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix feat(gateway): include bot identity in session_key for multi-bot Telegram setups [1 participants]