The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): one call shape for the re-stamp seam
teknium129c98eecc61e
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..33335e4f700--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1,2 @@+italodsfernandes+# PR #106019 salvagediff --git a/gateway/run_adapters.py b/gateway/run_adapters.pyindex 3fb09595102..8c1ad3834fc 100644--- a/gateway/run_adapters.py+++ b/gateway/run_adapters.py@@ -1438,12 +1438,7 @@ class GatewayAdapterLifecycleMixin:"""from gateway.profile_routing import ProfileRouteRejectedtry:- routed_profile = (- self._profile_name_for_source(source, adapter_profile=adapter_profile)- if adapter_profile is not None- else self._profile_name_for_source(source)- )- source.profile = routed_profile or adapter_profile+ source.profile = self._profile_name_for_source(source, adapter_profile=adapter_profile) or adapter_profileexcept ProfileRouteRejected:return Falsereturn Truediff --git a/tests/gateway/test_heartbeat_watch_restore.py b/tests/gateway/test_heartbeat_watch_restore.pyindex 88f74ac2e61..0e6195ebb82 100644--- a/tests/gateway/test_heartbeat_watch_restore.py+++ b/tests/gateway/test_heartbeat_watch_restore.py@@ -50,7 +50,7 @@ async def test_restore_retries_persisted_routes_in_their_own_profiles(tmp_path,runner.session_store = SessionStore(home / 'sessions', config)runner._heartbeat_watch = {}runner._start_heartbeat_poller = lambda: None- runner._profile_name_for_source = lambda source: source.profile+ runner._profile_name_for_source = lambda source, adapter_profile=None: source.profilerunner._adapter_for_source = lambda source: object()runner._run_in_executor_with_context = asyncio.to_threadoriginal = runner.session_store.list_sessionsdiff --git a/tests/gateway/test_multiplex_session_db_profile_scope.py b/tests/gateway/test_multiplex_session_db_profile_scope.pyindex d1a812e9aac..2def12f6e3a 100644--- a/tests/gateway/test_multiplex_session_db_profile_scope.py+++ b/tests/gateway/test_multiplex_session_db_profile_scope.py@@ -158,7 +158,7 @@ def test_primary_handler_rejected_route_falls_back_and_marks_sentinel(multiplex_runner.config = GatewayConfig(multiplex_profiles=True)route_calls = []- def rejecting_route(source):+ def rejecting_route(source, adapter_profile=None):route_calls.append(source.chat_id)raise ProfileRouteRejected("unserved profile")