The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(gateway): one list of route-bound model keys
Tekniume09268b29bcf
diff --git a/gateway/session_route_identity.py b/gateway/session_route_identity.pyindex 88bc59c05ec..9839d7d7ffc 100644--- a/gateway/session_route_identity.py+++ b/gateway/session_route_identity.py@@ -8,6 +8,17 @@ URL), never raw spellings. ``ollama``/``vllm`` resolve to ``custom``, ``deep-inf"""+# Every ``model:`` key that belongs to one endpoint; a route change drops them all, so none of the+# replaced endpoint's values is paired with the new one:+# - route itself (provider, base_url): which endpoint the turn goes to;+# - wire protocol (api_mode): how that endpoint speaks; another host may speak another protocol;+# - window (context_length): the replaced model's context size, wrong for the new one;+# - credentials (api_key, api, api_key_from, key_env, api_key_env): a key authenticates only the+# endpoint that issued it, and sending it anywhere else leaks it.+ROUTE_BOUND_KEYS = ('provider', 'base_url', 'api_mode', 'context_length',+ 'api_key', 'api', 'api_key_from', 'key_env', 'api_key_env')++def _named_entry(name: str, config: dict) -> dict | None:from hermes_cli.runtime_provider_custom import _get_named_custom_providerreturn _get_named_custom_provider(name, config=config, resolve_credentials=False)diff --git a/tests/gateway/test_session_route_identity.py b/tests/gateway/test_session_route_identity.pyindex ee0faf9c54a..7cd5e5b4c8a 100644--- a/tests/gateway/test_session_route_identity.py+++ b/tests/gateway/test_session_route_identity.py@@ -1,7 +1,7 @@"""Launch-route gates compare what the runtime resolves, not how the provider was spelled."""import pytest-from gateway.session_route_identity import resolved_route, same_route+from gateway.session_route_identity import ROUTE_BOUND_KEYS, resolved_route, same_routeA, B = 'http://127.0.0.1:8001/v1', 'http://127.0.0.1:8002/v1'CONFIG = {'providers': {'team': {'base_url': A, 'api_key': 'sk-team'}}}@@ -30,3 +30,10 @@ def test_resolved_route_identity_and_url():assert resolved_route({'provider': 'TEAM', 'base_url': B + '/'}, CONFIG) == ('custom:team', B)assert resolved_route({'provider': 'ollama', 'base_url': A}, {}) == ('custom', A)assert resolved_route({'provider': ''}, CONFIG) == ('auto', '')+++def test_route_bound_keys_cover_route_wire_window_and_credentials():+ assert isinstance(ROUTE_BOUND_KEYS, tuple)+ for key in ('provider', 'base_url', 'api_mode', 'context_length',+ 'api_key', 'api', 'api_key_from', 'key_env', 'api_key_env'):+ assert key in ROUTE_BOUND_KEYS