Skip to content

fix(gateway): avoid cross-profile session recovery (#58119 salvage) - #59325

Merged
benbarclay merged 1 commit into
mainfrom
salvage/58119-profile-session-recovery
Jul 7, 2026
Merged

fix(gateway): avoid cross-profile session recovery (#58119 salvage)#59325
benbarclay merged 1 commit into
mainfrom
salvage/58119-profile-session-recovery

Conversation

@teknium1

@teknium1 teknium1 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Session recovery no longer revives another profile's session: _recover_session_from_db rejects recovered rows whose session_key encodes a different profile namespace than the active profile.

Salvages #58119 by @tianma-if (cherry-picked, authorship preserved). Fixes #58032.

Root cause: _recover_session_from_db / hermes_state.find_latest_gateway_session_for_peer filter only by session_key or peer tuple (source/user/chat/thread) with no profile constraint. After turning multiplexing off, the peer-tuple fallback could revive an agent:coder:... row for an agent:main:... request — the user's chat silently resumes in the wrong profile's session.

Changes

  • gateway/session.py: profile-namespace guard on recovered rows; same-profile legacy migration preserved
  • tests/gateway/test_multiplex_phase0.py: rejects cross-profile fallback, allows same-profile fallback

Validation

Before After
Multiplex off, coder row matches peer tuple revived into main rejected, fresh session
Same-profile legacy row recovered recovered (unchanged)
tests (phase0 + session) 128/128 pass

Fifth PR in the multiplex isolation cluster (#59310, #59315, #59320, #59321).

Infographic

profile-scoped-session-recovery

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 6, 2026
@benbarclay
benbarclay merged commit f1fde49 into main Jul 7, 2026
31 checks passed
@benbarclay
benbarclay deleted the salvage/58119-profile-session-recovery branch July 7, 2026 08:25
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
justemu pushed a commit to justemu/hermes-agent that referenced this pull request Jul 18, 2026
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: multiplex_profiles: false leaves orphaned sessions that cause wrong profile routing

4 participants