Skip to content

The agent that grows with you

fix(gateway): room allow_silence honours the gateway's own config for its primary profile

kshitijk4poor78aa58f672ba
diff --git a/gateway/run_config_loaders.py b/gateway/run_config_loaders.py
index 25a5476d647..ade8a57056b 100644
--- a/gateway/run_config_loaders.py
+++ b/gateway/run_config_loaders.py
@@ -122,9 +122,13 @@ class GatewayConfigLoadersMixin:
from gateway.run import _get_channel_override, _load_gateway_config
from gateway.session_identity import identity_of
config = getattr(self, "config", None)
+ identity = identity_of(source)
+ runtime = identity.runtime_profile if identity is not None else (source.profile or None)
+ # ``self.config`` (including a ``gateway --config`` file) serves the primary profile; only a
+ # turn routed to another profile reads that profile's config.yaml.
+ routed = bool(runtime) and runtime != (getattr(self, "_primary_profile_name", None) or "default")
try:
- if (identity_of(source) is not None or source.profile
- or getattr(config, "multiplex_profiles", False) or config is None):
+ if config is None or routed:
raw = _load_gateway_config(self._resolve_profile_home_for_source(source) / "config.yaml")
# The loader's own two steps: merge every nested platform block, then the overrides of
# the block platform_section picks (a top-level ``<platform>:`` block first) win.
diff --git a/tests/gateway/test_room_allow_silence.py b/tests/gateway/test_room_allow_silence.py
index 1dc18ca33bb..c2b8a7ae3d8 100644
--- a/tests/gateway/test_room_allow_silence.py
+++ b/tests/gateway/test_room_allow_silence.py
@@ -276,3 +276,19 @@ async def test_unrecordable_silence_receipt_does_not_raise_into_delivery(monkeyp
"lane", {"final_response": "NO_REPLY"}, True, display_kind=None, reply_expected=True)
runner.session_store.lookup_by_session_key.assert_called_once_with("lane")
+
+
[email protected]("runtime,expected", [("primary", True), ("served", False)])
+def test_primary_profile_keeps_the_supplied_config(monkeypatch, tmp_path, runtime, expected):
+ runner = _runner(monkeypatch, tmp_path)
+ runner._primary_profile_name = "primary"
+ # A ``gateway --config`` file (runner.config) opts the room in; the profile home's file does not.
+ runner.config = GatewayConfig.from_dict({"platforms": {"telegram": {
+ "channel_overrides": {"-1001": {"allow_silence": True}}}}})
+ home = tmp_path / runtime
+ home.mkdir()
+ (home / "config.yaml").write_text("{}\n", encoding="utf-8")
+ source = _source()
+ source._identity = RoutingIdentity("primary", runtime, tmp_path, home, multiplexed=False)
+
+ assert runner._room_allow_silence(source) is (True if expected else None)