The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(hosted): decline questions without a reply channel
David Dudok de Wita0f040601ac0
diff --git a/gateway/session_local.py b/gateway/session_local.pyindex f85f27f1a39..08feb7cdd4c 100644--- a/gateway/session_local.py+++ b/gateway/session_local.py@@ -66,6 +66,15 @@ class LocalSessionAdapter(BasePlatformAdapter):# selects that rendering path without a plaintext fallback or a second waiter.return SendResult(success=True, message_id=uuid.uuid4().hex)+ async def send_clarify(self, chat_id, question, choices, clarify_id, session_key, metadata=None):+ policy = self.policies.get(chat_id)+ if policy is not None and policy.source == 'bot_room':+ # Hosted controls expose approvals only; acknowledging this question+ # would park the member on an answer nobody can submit.+ return SendResult(success=False, error='Clarification is unavailable in hosted rooms',+ error_kind='forbidden')+ return SendResult(success=True, message_id=clarify_id)+def authorize_local_source(runner, source):"""None for legacy/nonlocal routes; registered local adapters fail closed."""diff --git a/tests/gateway/test_hosted_clarification_refusal.py b/tests/gateway/test_hosted_clarification_refusal.pynew file mode 100644index 00000000000..f9f708374fe--- /dev/null+++ b/tests/gateway/test_hosted_clarification_refusal.py@@ -0,0 +1,16 @@+"""Persisted hosted policies cannot acknowledge a question without a reply channel."""+from dataclasses import replace++import pytest+++async def test_hosted_clarify_is_declined_before_waiting(owner, tmp_path):+ from gateway.session_local import LocalSessionAdapter+ from gateway.session_policy import build_policy+ adapter = LocalSessionAdapter(owner)+ adapter.policies['room'] = replace(build_policy({'source': 'cli', 'cwd': str(tmp_path), 'model': 'm'}, {}),+ source='bot_room', platform='bot_room')+ result = await adapter.send_clarify(chat_id='room', question='Which?', choices=['one', 'two'],+ clarify_id='question', session_key='route')+ assert result.success is False and result.error_kind == 'forbidden'