Skip to content

The agent that grows with you

test(gateway): a multiplexed owner's pick reads only its own profile's providers

Teknium02b325911dbc
diff --git a/tests/gateway/test_session_mutation_model_provider_replacement.py b/tests/gateway/test_session_mutation_model_provider_replacement.py
index a881e12071f..4b142ea1bc4 100644
--- a/tests/gateway/test_session_mutation_model_provider_replacement.py
+++ b/tests/gateway/test_session_mutation_model_provider_replacement.py
@@ -31,12 +31,12 @@ def peers():
t.join(timeout=5)
-async def pick(tmp_path, monkeypatch, before, after, provider, *, request=None):
+async def pick(tmp_path, monkeypatch, before, after, provider, *, request=None, hermes_home=None):
from gateway.session_mutation_model import prepare_model
from gateway.session_policy import build_policy, bind_launch_key, restore_policy
from gateway.run_turn_prepare import _resolve_policy_agent_runtime
from hermes_state import SessionDB
- monkeypatch.setenv('HERMES_HOME', str(tmp_path))
+ monkeypatch.setenv('HERMES_HOME', str(hermes_home or tmp_path))
(tmp_path / 'config.yaml').write_text(json.dumps(before))
private = {}
policy = build_policy({'cwd': str(tmp_path), 'model': 'original', **(request or {})},
@@ -128,6 +128,24 @@ async def test_appended_legacy_provider_keeps_inline_key_after_cold_restore(tmp_
assert runtime['base_url'].rstrip('/') == bu
+async def test_pick_reads_only_the_owning_profiles_config(tmp_path, monkeypatch):
+ """A multiplexed owner whose state.db lives under ``profiles/other`` resolves that profile's
+ entry, never the root profile's same-named one (the real-daemon test runs unmultiplexed)."""
+ other = tmp_path / 'profiles' / 'other'
+ other.mkdir(parents=True)
+ with peers() as (root_peer, root_url, b, bu):
+ (tmp_path / 'config.yaml').write_text(json.dumps({'providers': {'loop': {
+ 'base_url': root_url, 'api_key': 'root-only-key', 'models': {'switched': {}}}}}))
+ before = {'model': {'provider': 'custom', 'base_url': root_url, 'default': 'original'}}
+ after = {**before, 'providers': {'loop': {'base_url': bu, 'api_key': 'other-key',
+ 'models': {'switched': {}}}}}
+ config, runtime = await pick(other, monkeypatch, before, after, 'loop', hermes_home=tmp_path)
+ assert runtime['base_url'].rstrip('/') == bu
+ assert b.bearers == ['Bearer other-key'] and not root_peer.bearers
+ assert config['providers']['loop']['base_url'] == bu
+
+
@pytest.mark.platforms('linux')
def test_removed_provider_key_is_not_sent_to_retargeted_endpoint(tmp_path):
root = Path(__file__).resolve().parents[2]