fix(gateway): session key profile isolation + cron ticker cleanup + /new None guard#12108
Closed
zons-zhaozhy wants to merge 2 commits into
Closed
fix(gateway): session key profile isolation + cron ticker cleanup + /new None guard#12108zons-zhaozhy wants to merge 2 commits into
zons-zhaozhy wants to merge 2 commits into
Conversation
…d 'main' build_session_key() now accepts a 'profile' parameter (default 'main' for backward compatibility). When a non-default profile is active (HERMES_HOME points to ~/.hermes/profiles/<name>), session keys include the profile name (e.g. agent:work:telegram:dm:123) instead of always using 'agent:main:*', preventing session leakage between profiles. Closes NousResearch#12099
… finalize against None session 1. Cron ticker thread and MCP server connections were leaked when the gateway exited via should_exit_with_failure. The early return skipped cron_stop.set() and shutdown_mcp_servers(). Wrapped in try/finally so cleanup always runs. (Closes NousResearch#12175) 2. /new (session reset) called on_session_finalize with session_id=None when no prior session existed (old_entry is None). Added None guard to skip the hook invocation in that case. (Closes NousResearch#12176)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small gateway bugfixes:
build_session_key() hardcodes 'agent:main' in all session keys. When running
multiple Hermes profiles (HERMES_HOME=~/.hermes/profiles/), different
profiles share the same session keys, causing conversation leakage.
Fix: add profile parameter to build_session_key(). get_active_profile() returns
the active profile name for non-default profiles, or main for backward compat.
When should_exit_with_failure is True, return False skipped both
cron_stop.set() and shutdown_mcp_servers(), leaking the cron ticker
thread and MCP connections. Wrapped in try/finally so cleanup always runs.
_handle_reset_command() called on_session_finalize(session_id=None)
when no prior session existed. Skip hook invocation when _old_sid is None.
Testing: 3233 passed, 0 new failures (13 pre-existing).