Skip to content

fix(gateway): /profile reports the profile serving the source on multiplexed gateways - #62244

Closed
CocaKova wants to merge 2 commits into
NousResearch:mainfrom
CocaKova:pr/profile-command-source-scope
Closed

fix(gateway): /profile reports the profile serving the source on multiplexed gateways#62244
CocaKova wants to merge 2 commits into
NousResearch:mainfrom
CocaKova:pr/profile-command-source-scope

Conversation

@CocaKova

@CocaKova CocaKova commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

On a multiplexed gateway the process-level active profile is always the multiplexer's own (usually default), so /profile answers "default" in every chat regardless of which profile actually serves it. When personas are routed per-chat (/p/<profile>/ URL prefix, per-credential adapters, or per-chat mapping as in #61689), this makes working routing look broken — /profile is the first thing an operator reaches for to check it.

When gateway.multiplex_profiles is on, this reports source.profile when stamped and resolves the displayed home under that profile's runtime scope, mirroring the scoped /reset//new banner from #59003. The source-profile lookup and scope entry are gated on multiplex_profiles — the same gating as _run_agent and _reset_notice_session_info — so with multiplexing off (the default) a stamped source is ignored and single-profile gateways are byte-for-byte unchanged.

Tests: stamped source on a multiplexed gateway reports the profile's name and profiles/<name> home; stamped source with multiplexing off is ignored (regression); unstamped source unchanged; the existing custom-root /profile test still passes.

🤖 Generated with Claude Code

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 10, 2026
…e multiplexer's

On a multiplexed gateway the process-level active profile is always the
multiplexer's own (usually "default"), so /profile answered "default" in
every chat regardless of which profile actually served it — making
per-chat persona routing look broken when it was working.

Report source.profile (stamped by the /p/<profile>/ URL prefix, a
per-credential adapter, or a room->profile map) and resolve the
displayed home under that profile's runtime scope, mirroring the scoped
/reset banner (NousResearch#59003). Unstamped sources fall back to the active
profile and default home, so single-profile gateways are unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CocaKova
CocaKova force-pushed the pr/profile-command-source-scope branch from 881adc8 to 36c9e6d Compare July 10, 2026 18:54
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for targeting a real multiplexing diagnostics gap: current main's /profile still reads only the process-active profile at gateway/slash_commands.py:329-342.

Problems

  • The new handler uses source.profile and enters _profile_runtime_scope without checking multiplex_profiles. Existing consumers deliberately gate this behavior: gateway/session.py:1260-1269, gateway/run.py:12200-12203, and gateway/run.py:16835-16846.
  • The new stamped-source test constructs the default gateway config through _make_runner() (tests/gateway/test_status_command.py:34-40), while GatewayConfig.multiplex_profiles defaults to False (gateway/config.py:701). It does not test the intended multiplex path.

Suggested changes

  • Gate the source-profile lookup and runtime scope on self.config.multiplex_profiles, preserving the existing single-profile path.
  • Enable multiplexing in the stamped-source test and add a regression showing a stamped source remains ignored when multiplexing is off.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 11, 2026
Review follow-up: honor source.profile and enter _profile_runtime_scope
only when gateway.multiplex_profiles is on, mirroring the gating in
_run_agent, _reset_notice_session_info, and _resolve_profile_for_key.
When multiplexing is off (the default) a stamped source is ignored and
/profile reports the active profile and default home, byte-identical to
before this PR.

The stamped-source test now enables multiplexing (it previously
exercised the ungated path under the default config), and a new
regression asserts the stamp is ignored when multiplexing is off.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CocaKova

Copy link
Copy Markdown
Contributor Author

Both points addressed in 2e93839:

  • The source-profile lookup and _profile_runtime_scope entry are now gated on self.config.multiplex_profiles (same getattr pattern as _run_agent and _reset_notice_session_info). With multiplexing off, a stamped source is ignored and /profile reports the active profile and default home, byte-identical to pre-PR behavior.
  • The stamped-source test now sets multiplex_profiles = True, and a new regression (test_profile_command_ignores_stamp_when_multiplexing_off) asserts the stamp is ignored under the default config — verified it fails against the ungated handler.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #65700 — both commits cherry-picked onto current main with your authorship preserved in git log (rebase merge). Verified before merging that the bug still reproduced: your test failed on main for URL-prefix and routing-rule stamped sources (secondary-adapter chats were partially masked by the handler scope wrap, but the stamped-source path was fully broken). Thanks!

@teknium1 teknium1 closed this Jul 16, 2026
@teknium1 teknium1 added the area/profiles Multi-profile isolation, HERMES_HOME scoping label Jul 19, 2026
@CocaKova
CocaKova deleted the pr/profile-command-source-scope branch July 20, 2026 16:17
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 comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants