{"repo":"NousResearch/hermes-agent","public_id":"12805","display_label":"Feishu channel_prompt wiring and None-guard fixes","summary":"These issues and PRs center on the Feishu adapter missing channel_prompt resolution that other adapters (Discord, Slack) already have, plus a related AttributeError when event.channel_prompt is None. Some members also touch Anthropic max_tokens fallback and Discord free_response as adjacent fixes in the same changesets.","subsystem":"gateway","counts":{"members":5,"open_issues":0,"open_issues_distinct":0,"open_prs":0,"closed_issues":2,"merged_prs":1,"attempt_prs":2},"landed_fix":{"status":"merged_to_main","basis":"structural","pr":55958},"resolution":{"state":"unresolved","by":null},"freshness":{"state":"verified","last_verified_at":"2026-07-01T00:20:42+00:00","is_stale":false},"grouping":{"backbone":"STRUCTURAL_PARTIAL","link_density":0.33599999999999997},"fix_edges":[{"issue_number":12790,"pr_number":55958,"tier":"verified","basis":"closing_ref","confidence":0.95,"recoverable_from_timeline":true},{"issue_number":12805,"pr_number":55958,"tier":"verified","basis":"superseded_ref","confidence":0.9,"recoverable_from_timeline":false}],"members":[{"kind":"issue","number":12805,"title":"Feishu adapter missing channel_prompt resolution (unlike Discord/Slack)","url":null,"state":"closed"},{"kind":"issue","number":23682,"title":"AttributeError: 'NoneType' object has no 'channel_prompt' attribute","url":null,"state":"closed"},{"kind":"pr","number":12811,"title":"fix: Anthropic max_tokens + Feishu channel_prompt + Discord free_response","url":null,"state":"closed","close_reason":{"refs":[{"kind":"pr","value":"#12790","number":12790},{"kind":"pr","value":"#12805","number":12805},{"kind":"pr","value":"#12750","number":12750},{"kind":"pr","value":"#55958","number":55958},{"kind":"pr","value":"#12790","number":12790},{"kind":"pr","value":"#12805","number":12805},{"kind":"pr","value":"#12750","number":12750},{"kind":"pr","value":"#55958","number":55958}],"category":"implemented_elsewhere","implication":"superseded"},"merged":false},{"kind":"pr","number":23693,"title":"fix: guard event.channel_prompt access against None event","url":null,"state":"closed","close_reason":{"refs":[{"kind":"commit","value":"36bfe3a4490259eb8f89a84b7a9cad2a7c4de8ab","number":0},{"kind":"commit","value":"90a6336145cc48bcff945b159b7a9719dc933ef1","number":0}],"category":"implemented_elsewhere","implication":"superseded"},"merged":false,"is_fix_pr":true,"fix_tier":"suggested","fix_detail_withheld":true},{"kind":"pr","number":55958,"title":"fix(anthropic+feishu): model-gate max_tokens fallback; wire Feishu channel_prompt","url":null,"state":"merged","close_reason":{"category":"merged","implication":"superseded"},"merged":true,"is_fix_pr":true,"fix_tier":"verified","files_changed":["agent/chat_completion_helpers.py","plugins/platforms/feishu/adapter.py","tests/gateway/test_feishu_channel_prompts.py"],"fix_hunks":[{"file":"agent/chat_completion_helpers.py","hunks":["@@ -741,14 +741,26 @@ def build_api_kwargs(agent, api_messages: list) -> dict:\n     if agent.provider_data_collection:\n         _prefs[\"data_collection\"] = agent.provider_data_collection\n \n-    # Claude max-output override on aggregators\n+    # Anthropic-compatible max-output fallback (last resort only — applied in\n+    # build_kwargs *after* ephemeral/user/profile max_tokens, never overriding\n+    # an explicit value).  Model-gated, not URL-gated: any chat-completions\n+    # proxy serving a Claude/MiniMax/Qwen3 model needs max_tokens, because the\n+    # Anthropic Messages API treats it as mandatory and proxies that omit it\n+    # (AWS Bedrock, NVIDIA, LiteLLM, vLLM, corporate gateways) default as low\n+    # as 4096 output tokens — easily exhausted by thinking + large tool calls\n+    # like write_file/patch.  OpenRouter/Nous were the only routes covered\n+    # before; gating on _ANTHROPIC_OUTPUT_LIMITS membership covers them all.\n     _ant_max = None\n-    if (_is_or or _is_nous) and \"claude\" in (agent.model or \"\").lower():\n-        try:\n-            from agent.anthropic_adapter import _get_anthropic_max_output\n+    try:\n+        from agent.anthropic_adapter import (\n+            _get_anthropic_max_output,\n+            _ANTHROPIC_OUTPUT_LIMITS,\n+        )\n+        _model_norm = (agent.model or \"\").lower().replace(\".\", \"-\")\n+        if any(key in _model_norm for key in _ANTHROPIC_OUTPUT_LIMITS):\n             _ant_max = _get_anthropic_max_output(agent.model)\n-        except Exception:\n-            pass\n+    except Exception:\n+        pass\n \n     # Qwen session metadata\n     _qwen_meta = None"]},{"file":"plugins/platforms/feishu/adapter.py","hunks":["@@ -2892,6 +2892,7 @@ async def _handle_reaction_event(self, event_type: str, data: Any) -> None:\n             source=source,\n             raw_message=data,\n             message_id=message_id,\n+            channel_prompt=self._resolve_channel_prompt(chat_id),\n             timestamp=datetime.now(),\n         )\n         logger.info(\"[Feishu] Routing reaction %s:%s on bot message %s as synthetic event\", action, emoji_type, message_id)","@@ -2954,6 +2955,7 @@ async def _handle_card_action_event(self, data: Any) -> None:\n             source=source,\n             raw_message=data,\n             message_id=token or str(uuid.uuid4()),\n+            channel_prompt=self._resolve_channel_prompt(chat_id),\n             timestamp=datetime.now(),\n         )\n         logger.info(\"[Feishu] Routing card action %r from %s in %s as synthetic command\", action_tag, open_id, chat_id)","@@ -3156,6 +3158,18 @@ def _clear_webhook_anomaly(self, remote_ip: str) -> None:\n     # Inbound processing pipeline\n     # =========================================================================\n \n+    def _resolve_channel_prompt(self, chat_id: str, parent_id: str | None = None) -> str | None:\n+        \"\"\"Resolve a Feishu per-channel system prompt.\n+\n+        Mirrors the Discord/Slack behaviour so ``channel_prompts: {<chat_id>:\n+        \"<prompt>\"}`` in ``PlatformConfig.extra`` is honoured for Feishu chats\n+        instead of being silently ignored.\n+        \"\"\"\n+        from gateway.platforms.base import resolve_channel_prompt\n+        _config = getattr(self, \"config\", None)\n+        _extra = getattr(_config, \"extra\", None) or {}\n+        return resolve_channel_prompt(_extra, chat_id, parent_id)\n+\n     async def _process_inbound_message(\n         self,\n         *,","@@ -3233,6 +3247,7 @@ async def _process_inbound_message(\n             media_types=media_types,\n             reply_to_message_id=reply_to_message_id,\n             reply_to_text=reply_to_text,\n+            channel_prompt=self._resolve_channel_prompt(chat_id, thread_id or None),\n             timestamp=datetime.now(),\n         )\n         await self._dispatch_inbound_event(normalized)"]},{"file":"tests/gateway/test_feishu_channel_prompts.py","hunks":["@@ -0,0 +1,88 @@\n+\"\"\"Tests for Feishu per-channel prompt resolution.\n+\n+Feishu previously ignored ``channel_prompts`` config (unlike Discord/Slack).\n+These tests verify that ``_resolve_channel_prompt`` reads the adapter's\n+``config.extra`` and that the resolved prompt is attached to the dispatched\n+``MessageEvent`` for the inbound, reaction, and card-action paths.\n+\"\"\"\n+\n+import asyncio\n+import json\n+from types import SimpleNamespace\n+from unittest.mock import AsyncMock, Mock\n+\n+from gateway.config import PlatformConfig\n+\n+\n+def _build_adapter(extra=None):\n+    from plugins.platforms.feishu.adapter import FeishuAdapter\n+\n+    adapter = FeishuAdapter.__new__(FeishuAdapter)\n+    adapter.config = PlatformConfig(extra=extra or {})\n+    adapter._bot_open_id = \"ou_bot\"\n+    adapter._bot_user_id = \"\"\n+    adapter._bot_name = \"Hermes\"\n+    adapter._download_feishu_message_resources = AsyncMock(return_value=([], []))\n+    adapter._fetch_message_text = AsyncMock(return_value=None)\n+    adapter.get_chat_info = AsyncMock(return_value={\"name\": \"Test Chat\"})\n+    adapter._resolve_sender_profile = AsyncMock(\n+        return_value={\"user_id\": \"u1\", \"user_name\": \"Alice\", \"user_id_alt\": None}\n+    )\n+    adapter._resolve_source_chat_type = Mock(return_value=\"group\")\n+    adapter.build_source = Mock(return_value=SimpleNamespace(thread_id=None))\n+    adapter._dispatch_inbound_event = AsyncMock()\n+    return adapter\n+\n+\n+def _run_inbound(adapter, chat_id=\"oc_chat\"):\n+    message = SimpleNamespace(\n+        content=json.dumps({\"text\": \"plain message\"}),\n+        message_type=\"text\",\n+        message_id=\"m\",\n+        mentions=[],\n+        chat_id=chat_id,\n+        parent_id=None,\n+        upper_message_id=None,\n+        thread_id=None,\n+    )\n+    asyncio.run(\n+        adapter._process_inbound_message(\n+            data=message, message=message, sender_id=None, chat_type=\"group\", message_id=\"m\",\n+        )\n+    )\n+    return adapter._dispatch_inbound_event.call_args.args[0]\n+\n+\n+def test_resolve_channel_prompt_exact_match():\n+    adapter = _build_adapter({\"channel_prompts\": {\"oc_chat\": \"Be terse.\"}})\n+    assert adapter._resolve_channel_prompt(\"oc_chat\") == \"Be terse.\"\n+\n+\n+def test_resolve_channel_prompt_parent_fallback():\n+    adapter = _build_adapter({\"channel_prompts\": {\"oc_parent\": \"Inherit me.\"}})\n+    assert adapter._resolve_channel_prompt(\"oc_thread\", \"oc_parent\") == \"Inherit me.\"\n+\n+\n+def test_resolve_channel_prompt_no_match_returns_none():\n+    adapter = _build_adapter({\"channel_prompts\": {\"oc_other\": \"Nope.\"}})\n+    assert adapter._resolve_channel_prompt(\"oc_chat\") is None\n+\n+\n+def test_resolve_channel_prompt_missing_config_is_safe():\n+    # __new__ adapter without a config attribute (defensive getattr path).\n+    from plugins.platforms.feishu.adapter import FeishuAdapter\n+\n+    bare = FeishuAdapter.__new__(FeishuAdapter)\n+    assert bare._resolve_channel_prompt(\"oc_chat\") is None\n+\n+\n+def test_inbound_event_carries_channel_prompt():\n+    adapter = _build_adapter({\"channel_prompts\": {\"oc_chat\": \"Feishu role prompt.\"}})\n+    event = _run_inbound(adapter, chat_id=\"oc_chat\")\n+    assert event.channel_prompt == \"Feishu role prompt.\"\n+\n+\n+def test_inbound_event_no_prompt_when_unconfigured():\n+    adapter = _build_adapter({\"channel_prompts\": {\"oc_other\": \"Different chat.\"}})\n+    event = _run_inbound(adapter, chat_id=\"oc_chat\")\n+    assert event.channel_prompt is None\n"]}]}],"trust":{"default_tier":"verified","includes_suggested":false}}