The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): every adapter send_voice accepts the dispatch's is_voice kwarg
teknium1fd94fe9b93bb
diff --git a/gateway/platforms/weixin.py b/gateway/platforms/weixin.pyindex 260981f0d03..7c5ef23ca29 100644--- a/gateway/platforms/weixin.py+++ b/gateway/platforms/weixin.py@@ -1111,7 +1111,7 @@ class WeixinAdapter(OwnAccessPolicyMixin, BasePlatformAdapter):async def send_video(self, chat_id: str, video_path: str, caption: Optional[str] = None, reply_to=None, metadata=None) -> SendResult:return await self._send_file_result(chat_id, video_path, caption or "", "send_video")- async def send_voice(self, chat_id: str, audio_path: str, caption: Optional[str] = None, reply_to=None, metadata=None) -> SendResult:+ async def send_voice(self, chat_id: str, audio_path: str, caption: Optional[str] = None, reply_to=None, metadata=None, **kwargs) -> SendResult:# Native outbound voice bubbles are not proven-working upstream; a file attachment at least plays (even .silk).return await self._send_file_result(chat_id, audio_path, caption or self.warning_text("[voice message as attachment]"), "send_voice", force_file_attachment=True)diff --git a/plugins/platforms/line/adapter.py b/plugins/platforms/line/adapter.pyindex 6a5ee0d5cd2..ee9842a72ab 100644--- a/plugins/platforms/line/adapter.py+++ b/plugins/platforms/line/adapter.py@@ -818,7 +818,8 @@ class LineAdapter(BasePlatformAdapter):return await self._send_messages(chat_id, msgs + ([_text_message(caption)] if caption else []))async def send_voice(- self, chat_id: str, audio_path: str, duration_ms: int = 1000, metadata: Optional[Dict[str, Any]] = None+ self, chat_id: str, audio_path: str, duration_ms: int = 1000, metadata: Optional[Dict[str, Any]] = None,+ **kwargs: Any,) -> SendResult:path, err = self._check_media_file("audio", audio_path)if err:diff --git a/plugins/platforms/mattermost/adapter.py b/plugins/platforms/mattermost/adapter.pyindex 94f9822f145..2dde18e075b 100644--- a/plugins/platforms/mattermost/adapter.py+++ b/plugins/platforms/mattermost/adapter.py@@ -311,7 +311,7 @@ class MattermostAdapter(BasePlatformAdapter):return await self._send_local_file(chat_id, file_path, caption, reply_to, file_name, metadata)async def send_voice(self, chat_id: str, audio_path: str, caption: Optional[str] = None,- reply_to: Optional[str] = None, metadata: _Metadata = None) -> SendResult:+ reply_to: Optional[str] = None, metadata: _Metadata = None, **kwargs: Any) -> SendResult:return await self._send_local_file(chat_id, audio_path, caption, reply_to, metadata=metadata)async def send_video(self, chat_id: str, video_path: str, caption: Optional[str] = None,diff --git a/tests/gateway/test_send_voice_dispatch_signatures.py b/tests/gateway/test_send_voice_dispatch_signatures.pynew file mode 100644index 00000000000..3f4679cdde2--- /dev/null+++ b/tests/gateway/test_send_voice_dispatch_signatures.py@@ -0,0 +1,40 @@+"""Every platform adapter's ``send_voice`` must accept the ``is_voice`` keyword the base media+dispatch passes (``BasePlatformAdapter._deliver_media_from_response`` →+``send_voice(..., is_voice=is_voice)``). An explicit signature without it raises ``TypeError`` and+the attachment is silently dropped (#102221, #116776 — Matrix; same class in line/mattermost/weixin)."""++from __future__ import annotations++import ast+import inspect+from pathlib import Path++import pytest++_ROOT = Path(__file__).resolve().parents[2]+_ADAPTER_FILES = sorted(+ p for p in list((_ROOT / "plugins" / "platforms").glob("*/adapter.py")) + list((_ROOT / "gateway" / "platforms").glob("*.py"))+ if "async def send_voice" in p.read_text(encoding="utf-8")+)+++def _send_voice_defs(path: Path):+ tree = ast.parse(path.read_text(encoding="utf-8"))+ return [n for n in ast.walk(tree) if isinstance(n, ast.AsyncFunctionDef) and n.name == "send_voice"]++[email protected]("path", _ADAPTER_FILES, ids=lambda p: str(p.relative_to(_ROOT)))+def test_every_send_voice_accepts_is_voice(path: Path) -> None:+ for fn in _send_voice_defs(path):+ names = {a.arg for a in fn.args.args + fn.args.kwonlyargs}+ assert fn.args.kwarg is not None or "is_voice" in names, (+ f"{path}: send_voice() rejects the dispatch's is_voice kwarg — add **kwargs or is_voice"+ )+++def test_base_dispatch_passes_is_voice_to_send_voice() -> None:+ """Guards the contract from the other side: the dispatch really passes ``is_voice``."""+ from gateway.platforms.base import BasePlatformAdapter++ src = inspect.getsource(BasePlatformAdapter)+ assert "self.send_voice(chat_id=chat_id, audio_path=path, metadata=metadata, is_voice=is_voice)" in src