The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): run_inbound resolves adapters through the intake/delivery seams
teknium12ab825d931dd
diff --git a/gateway/run_inbound.py b/gateway/run_inbound.pyindex 3e03b3f3739..17db75bd8d6 100644--- a/gateway/run_inbound.py+++ b/gateway/run_inbound.py@@ -111,7 +111,7 @@ class GatewayInboundMixin:if pairing_store._is_rate_limited(platform_name, source.user_id):returncode = pairing_store.generate_code(platform_name, source.user_id, source.user_name or "")- adapter = self._adapter_for_source(source)+ adapter = self._delivery_adapter_for(source)if code:reply = pairing_code_reply(platform_name, code, pairing_profile_arg(pairing_store))else:@@ -132,7 +132,7 @@ class GatewayInboundMixin:if pairing_store is None or pairing_store.has_recent_decline(platform_name, source.user_id):returnpairing_store.record_decline(platform_name, source.user_id)- adapter = self._adapter_for_source(source)+ adapter = self._delivery_adapter_for(source)if not adapter:returnconfig = getattr(self, "config", None)@@ -198,7 +198,7 @@ class GatewayInboundMixin:# The routed adapter's extra carries a secondary profile's own list; ``_config`` is the default's._slack_adapter = Nonewith suppress(Exception):- _slack_adapter = self._adapter_for_source(source)+ _slack_adapter = self._intake_adapter_for(source)if (# See #51899.not is_internal@@ -397,7 +397,7 @@ class GatewayInboundMixin:)# The clarify callback pauses the platform typing/status indicator while waiting so# Slack users can type; the active agent resumes now, so re-enable its indicator.- _clarify_adapter = self._adapter_for_source(source)+ _clarify_adapter = self._delivery_adapter_for(source)if _clarify_adapter:try:_clarify_adapter.resume_typing_for_chat(source.chat_id)@@ -426,7 +426,7 @@ class GatewayInboundMixin:# prose is routed, so its buttons stop advertising a dead answer path. The pop inside# retire_clarify_card runs before its first await, so the agent thread's own expiry# notice (scheduled once the wait unblocks) finds nothing and stays a no-op.- _clarify_adapter = self._adapter_for_source(source)+ _clarify_adapter = self._delivery_adapter_for(source)# Class lookup: a MagicMock adapter must not fabricate the method.if callable(getattr(type(_clarify_adapter), "retire_clarify_card", None)):try:@@ -567,7 +567,7 @@ class GatewayInboundMixin:) -> None:"""Merge *event* into the source adapter's pending slot (no-op without an adapter)."""from gateway.platforms.base import merge_pending_message_event- adapter = self._adapter_for_source(source)+ adapter = self._delivery_adapter_for(source)if adapter:merge_pending_message_event(adapter._pending_messages, _quick_key, event, merge_text=merge_text)@@ -622,7 +622,7 @@ class GatewayInboundMixin:if effective_busy_input_mode != "queue":self._hm_merge_pending_for_source(source, _quick_key, event, merge_text=True)else:- adapter = self._adapter_for_source(source)+ adapter = self._delivery_adapter_for(source)if adapter:self._enqueue_fifo(_quick_key, event, adapter)return True@@ -667,7 +667,7 @@ class GatewayInboundMixin:_interrupt_text = event.textif self._pending_event_audio_paths(event):_interrupt_text, _ = await self._transcribe_and_echo_pending_voice(- event, self._adapter_for_source(source), source, event.text or "",+ event, self._delivery_adapter_for(source), source, event.text or "",log_context="Voice-priority-interrupt",)elif not _interrupt_text and getattr(event, "media_urls", None):@@ -1243,7 +1243,7 @@ class GatewayInboundMixin:# turn for this session NOW: re-stage the orphans in FIFO order and enqueue the incoming event# behind them, so arrival order (#28503) holds: oldest orphan runs as this turn, the rest drain# in order, the new message last.- _orphan_adapter = self._adapter_for_source(source)+ _orphan_adapter = self._delivery_adapter_for(source)if _orphan_adapter is None or getattr(event, "internal", False) or event.get_command():return event, source, is_internal_rescued = self._rescue_orphaned_overflow(_quick_key, _orphan_adapter)@@ -1495,7 +1495,7 @@ class GatewayInboundMixin:# quality in real time. On transcription failure do NOT send a hardcoded notice: that# bypassed the LLM and produced two replies; enrichment leaves one neutral marker instead.if _successful_transcripts and self._should_echo_stt_transcripts():- _echo_adapter = self._adapter_for_source(source)+ _echo_adapter = self._delivery_adapter_for(source)if _echo_adapter:_echo_meta = self._thread_metadata_for_source(source, self._reply_anchor_for_event(event))await self._echo_stt_transcripts(_echo_adapter, source, _successful_transcripts, metadata=_echo_meta)@@ -1665,7 +1665,7 @@ class GatewayInboundMixin:message_text, cwd=_msg_cwd, context_length=_msg_ctx_len, allowed_root=_msg_cwd)if _ctx_result.blocked:- _adapter = self._adapter_for_source(source)+ _adapter = self._delivery_adapter_for(source)if _adapter:await _adapter.send(source.chat_id,@@ -1873,7 +1873,7 @@ class GatewayInboundMixin:)return False- adapter = self._adapter_for_source(source)+ adapter = self._delivery_adapter_for(source)if adapter is None:return False