Skip to content

The agent that grows with you

refactor(gateway): identity-first session keys; mark boot-only ambient profile reads

teknium194218e192e6e
diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.py
index 899cb9589e3..e6180a9ba56 100644
--- a/gateway/platforms/api_server.py
+++ b/gateway/platforms/api_server.py
@@ -1308,7 +1308,7 @@ class APIServerAdapter(OpenAICompatRoutesMixin, BasePlatformAdapter):
profile_name = ""
with suppress(Exception):
from hermes_cli.profiles import get_active_profile_name
- profile = get_active_profile_name()
+ profile = get_active_profile_name() # launch profile, pre-identity (advertised model name)
if profile and profile not in {"default", "custom"}:
profile_name = profile
return resolve_effective_model(explicit, profile_name, "hermes-agent")
diff --git a/gateway/run.py b/gateway/run.py
index 3bf9d1605b1..8ee83f0a34d 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -1613,7 +1613,7 @@ def _cron_tick_profile_homes(config: object) -> list[tuple[str, "Path"]]:
from hermes_cli.profiles import get_active_profile_name, get_profile_dir
homes = _multiplex_profile_homes(config)
- active = get_active_profile_name() or "default"
+ active = get_active_profile_name() or "default" # launch profile, pre-identity (ticker boot)
if any(name == active for name, _home in homes):
return homes
try:
@@ -3841,9 +3841,14 @@ class GatewayRunner(
pass
config = getattr(self, "config", None)
# Mirror SessionStore._resolve_profile_for_key so this fallback yields the primary path's
- # namespace: None (legacy agent:main) unless multiplexing is on, then the active profile.
+ # namespace: None (legacy agent:main) unless multiplexing is on, then the pinned identity's
+ # runtime profile, the source stamp, or the active profile.
+ from gateway.session_identity import identity_of
+ identity = identity_of(source)
_profile = None
- if getattr(config, "multiplex_profiles", False):
+ if identity is not None:
+ _profile = identity.session_key_profile
+ elif getattr(config, "multiplex_profiles", False):
if source.profile:
_profile = source.profile
else:
diff --git a/gateway/run_adapters.py b/gateway/run_adapters.py
index 1c9b07afdcb..01212bcec7e 100644
--- a/gateway/run_adapters.py
+++ b/gateway/run_adapters.py
@@ -853,7 +853,7 @@ class GatewayAdapterLifecycleMixin:
from hermes_cli.profiles import get_active_profile_name
except Exception:
return 0
- active = get_active_profile_name() or "default"
+ active = get_active_profile_name() or "default" # launch profile, pre-identity (adapter boot)
connected = 0
claimed = self._primary_resource_claims(active)
profile_homes = _multiplex_profile_homes(self.config)