Skip to content

fix(gateway): accept named-profile namespace in session-key parsing and sibling lookup - #105977

Closed
daerias wants to merge 1 commit into
NousResearch:mainfrom
daerias:fix/session-key-namespace-run
Closed

daerias wants to merge 1 commit into
NousResearch:mainfrom
daerias:fix/session-key-namespace-run

Conversation

@daerias

@daerias daerias commented Sep 8, 2026

Copy link
Copy Markdown

What

Named-profile gateway sessions use namespaced session keys (agent:<profile>:..., see _session_key_namespace() in gateway/session.py). Two core helpers still assume the default-profile literal, so named-profile sessions are misparsed or their sibling lookups silently fail:

Spot Symptom under a named profile Fix
_parse_session_key() key parses to None → routing degrades to the LRU _session_sources fallback accept any non-empty namespace
_sibling_thread_run_keys() sibling lookup returns [] → /stop says "no active task to stop" while the sibling keeps running derive prefix from _session_key_namespace(profile)

Why

Changes

  • _parse_session_key(): accept any non-empty namespace slot instead of asserting parts[1] == "main". Malformed keys (agent::..., wrong prefix, too few parts) still return None.
  • _sibling_thread_run_keys(): build the prefix via _session_key_namespace(getattr(source, "profile", None)) — byte-identical agent:main for default/unset profiles.

No behavior change for the default main case.

Tests

Reproduce: with a named profile serving any chat platform, trigger a background-process notification or /stop a sibling thread run — before: silent fallback / "no active task to stop"; after: correct routing and sibling match.

  • 4 new regression tests: named-profile parsing (plain + dm/thread-with-extra), malformed-key rejection, named-profile sibling matching.
  • pytest tests/gateway/test_background_process_notifications.py tests/gateway/test_stop_thread_sibling.py -q → 30 passed.
  • Full gateway suite on this host: 7889 passed, 14 failed. Of those, the same 7 environment-dependent failures reproduce identically on clean main (verified in isolation on main@b2aa855b62); the other 7 pass in isolation on this branch — order-dependent suite flakiness, not caused by this change.

Platforms

Tested on macOS (arm64). The changed paths are platform-independent; Linux-gated gateway paths were not exercised live on this host.

Related

Not in scope

_build_process_event_source() in run_notifications.py still rewrites named-profile keys to agent:main before parsing — redundant and harmless after this fix; candidate for a separate cleanup PR.

Checklist

  • Conventional commit (fix(gateway): ...)
  • Regression tests for both fixed paths; targeted suites green
  • No unrelated changes; default-profile (agent:main) behavior byte-identical

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/sessions Session lifecycle, resume, persistence, history area/profiles Multi-profile isolation, HERMES_HOME scoping sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state duplicate This issue or pull request already exists labels Sep 8, 2026
@alt-glitch

Copy link
Copy Markdown

This was generated by AI during triage.

Duplicate of #105942, which landed first with the same _parse_session_key / _sibling_thread_run_keys namespace fix (and also patches gateway/run_notifications.py). #105943 is a third copy. Thanks for the issue report (#105931); if this PR has a delta the others lack, please note it here.

@daerias

daerias commented Sep 8, 2026

Copy link
Copy Markdown
Author

Thanks for the triage. Checked #105942's diff — it covers both spots plus the run_notifications.py cleanup, so no reason to keep this one open. Closing this in favor of it. Thanks @kokhlo for the complete fix!

@daerias daerias closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping area/sessions Session lifecycle, resume, persistence, history comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists 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.

2 participants