Skip to content

The agent that grows with you

fix(gateway): hosted room members no longer stall for an hour on a question nobody can answer

Tekniume6a16600aea7
diff --git a/gateway/session_hosted_rpc.py b/gateway/session_hosted_rpc.py
index d21d68988c3..bdcb7e92006 100644
--- a/gateway/session_hosted_rpc.py
+++ b/gateway/session_hosted_rpc.py
@@ -76,8 +76,16 @@ class HostedRoomAuthorityRPC:
from gateway.run import _load_gateway_config, _resolve_gateway_model
from gateway.session_policy import build_policy
from gateway.session_local import create_local_session
+ from agent.skill_utils import parse_config_string_list
private = {}
- policy = build_policy({'source': 'gui'}, _load_gateway_config(), private_secrets=private)
+ config = _load_gateway_config()
+ # A room has no clarification reply (group controls expose approvals only), so a member
+ # turn that called clarify would block for clarify_timeout with its question unseen. As
+ # for cron, freeze it out; the member asks its question in the room reply instead.
+ agent = dict(config.get('agent') or {})
+ agent['disabled_toolsets'] = sorted(
+ set(parse_config_string_list(agent.get('disabled_toolsets'))) | {'clarify'})
+ policy = build_policy({'source': 'gui'}, {**config, 'agent': agent}, private_secrets=private)
policy = replace(policy, source='bot_room', platform='bot_room',
model=policy.model or _resolve_gateway_model(policy.config()),
toolsets=tuple(sorted(set(policy.toolsets) | {'bot_room'})))
diff --git a/tests/gateway/test_session_hosted_rpc.py b/tests/gateway/test_session_hosted_rpc.py
index 4bd3bf744ca..8ca7985b007 100644
--- a/tests/gateway/test_session_hosted_rpc.py
+++ b/tests/gateway/test_session_hosted_rpc.py
@@ -305,3 +305,30 @@ def test_queued_cancellation_is_a_cancelled_receipt_not_storage_unavailable(host
settle_session_input(authority.db, epoch=authority.epoch, admission_id=row['admission_id'], generation=row['generation'], outcome='completed', result=None)
with pytest.raises(RuntimeStoreError, match='storage_unavailable'):
rpc.history(**coords, session_id=sid)
+
+
+def test_room_member_turns_cannot_block_on_an_unanswerable_clarify(hosted_owner, monkeypatch):
+ """A room has no clarification reply and hosted principals lack session:respond, so a
+ member turn that called clarify would block for clarify_timeout with its question never
+ shown. The frozen member policy must exclude the tool even when the profile's toolsets
+ (here the hermes-cli bundle) include it; the member asks in its room reply instead."""
+ from gateway import run
+ from gateway.session_hosted_rpc import HostedRoomAuthorityRPC
+ from gateway.session_local_recovery import local_adapter_map
+ from gateway.config import Platform
+ from agent.skill_utils import parse_config_string_list
+ from model_tools import get_tool_definitions
+
+ authority, loop, principal, _ = hosted_owner
+ monkeypatch.setattr(run, '_load_gateway_config', lambda: {
+ 'model': {'default': 'fixture'}, 'platform_toolsets': {'cli': ['hermes-cli']}})
+ rpc = HostedRoomAuthorityRPC(authority, loop, room_id='room', member_id='one', profile='default',
+ principal=principal, authorize=lambda *args: True)
+ sid = rpc.create(profile='default', title='Group: room', source='bot_room')['session_id']
+ policy = local_adapter_map(authority)[Platform.LOCAL].policies[sid]
+ # The same derivation the turn uses: frozen toolsets minus the frozen agent.disabled_toolsets.
+ disabled = parse_config_string_list((policy.config().get('agent') or {}).get('disabled_toolsets'))
+ tools = {t['function']['name'] for t in get_tool_definitions(
+ enabled_toolsets=list(policy.toolsets), disabled_toolsets=disabled or None, quiet_mode=True)}
+ assert 'terminal' in tools
+ assert 'clarify' not in tools