Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(bot): pass sender_name in all channel adapters (#3399)
Zayn Jarvis8da91a860bde
diff --git a/bot/bridge/src/whatsapp.ts b/bot/bridge/src/whatsapp.tsindex 632386ac2..e2d6b4a9b 100644--- a/bot/bridge/src/whatsapp.ts+++ b/bot/bridge/src/whatsapp.ts@@ -21,6 +21,7 @@ export interface InboundMessage {id: string;sender: string;pn: string;+ pushName: string;content: string;timestamp: number;isGroup: boolean;@@ -125,6 +126,7 @@ export class WhatsAppClient {id: msg.key.id || '',sender: msg.key.remoteJid || '',pn: msg.key.remoteJidAlt || '',+ pushName: msg.pushName || '',content,timestamp: msg.messageTimestamp as number,isGroup,diff --git a/bot/tests/test_channel_sender_name.py b/bot/tests/test_channel_sender_name.pynew file mode 100644index 000000000..2d944a057--- /dev/null+++ b/bot/tests/test_channel_sender_name.py@@ -0,0 +1,34 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""Regression tests for channel sender names."""++import json+import sys+from pathlib import Path++import pytest++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))++from vikingbot.bus.queue import MessageBus # noqa: E402+from vikingbot.channels.whatsapp import WhatsAppChannel # noqa: E402+from vikingbot.config.schema import WhatsAppChannelConfig # noqa: E402+++async def test_whatsapp_sender_name_falls_back_to_sender_id():+ bus = MessageBus()+ channel = WhatsAppChannel(WhatsAppChannelConfig(), bus)++ await channel._handle_bridge_message(+ json.dumps(+ {+ "type": "message",+ "sender": "[email protected]",+ "content": "hello",+ }+ )+ )++ inbound = await bus.consume_inbound()+ assert inbound.sender_name == "123456789"diff --git a/bot/vikingbot/channels/base.py b/bot/vikingbot/channels/base.pyindex 0051ae6ad..d5d3ef23a 100644--- a/bot/vikingbot/channels/base.py+++ b/bot/vikingbot/channels/base.py@@ -142,9 +142,9 @@ class BaseChannel(ABC):async def _handle_message(self,sender_id: str,- sender_name: str,chat_id: str,content: str,+ sender_name: str | None = None,need_reply: bool = True,media: list[str] | None = None,metadata: dict[str, Any] | None = None,@@ -156,6 +156,8 @@ class BaseChannel(ABC):Args:sender_id: The sender's identifier.+ sender_name: The sender's display name; falls back to sender_id+ downstream when unavailable.chat_id: The chat/channel identifier.content: Message text content.media: Optional list of media URLs.diff --git a/bot/vikingbot/channels/dingtalk.py b/bot/vikingbot/channels/dingtalk.pyindex 9dc32d0dc..e930ed264 100644--- a/bot/vikingbot/channels/dingtalk.py+++ b/bot/vikingbot/channels/dingtalk.py@@ -238,6 +238,7 @@ class DingTalkChannel(BaseChannel):logger.info(f"DingTalk inbound: {content} from {sender_name}")await self._handle_message(sender_id=sender_id,+ sender_name=sender_name or sender_id,chat_id=sender_id, # For private chat, chat_id == sender_idcontent=str(content),metadata={diff --git a/bot/vikingbot/channels/discord.py b/bot/vikingbot/channels/discord.pyindex 740300637..a974c6c58 100644--- a/bot/vikingbot/channels/discord.py+++ b/bot/vikingbot/channels/discord.py@@ -240,6 +240,7 @@ class DiscordChannel(BaseChannel):await self._handle_message(sender_id=sender_id,+ sender_name=author.get("global_name") or author.get("username") or sender_id,chat_id=channel_id,content="\n".join(p for p in content_parts if p) or "[empty message]",media=media_paths,diff --git a/bot/vikingbot/channels/mochat.py b/bot/vikingbot/channels/mochat.pyindex d864a1d39..c8a2f525d 100644--- a/bot/vikingbot/channels/mochat.py+++ b/bot/vikingbot/channels/mochat.py@@ -847,6 +847,7 @@ class MochatChannel(BaseChannel):body = build_buffered_body(entries, is_group) or "[empty message]"await self._handle_message(sender_id=last.author,+ sender_name=last.sender_name or last.sender_username or last.author,chat_id=target_id,content=body,metadata={diff --git a/bot/vikingbot/channels/qq.py b/bot/vikingbot/channels/qq.pyindex 527fb931c..332830c78 100644--- a/bot/vikingbot/channels/qq.py+++ b/bot/vikingbot/channels/qq.py@@ -131,6 +131,11 @@ class QQChannel(BaseChannel):await self._handle_message(sender_id=user_id,+ sender_name=str(+ getattr(author, "username", None)+ or getattr(author, "name", None)+ or user_id+ ),chat_id=user_id,content=content,metadata={"message_id": data.id},diff --git a/bot/vikingbot/channels/telegram.py b/bot/vikingbot/channels/telegram.pyindex 9e979769e..f106464bc 100644--- a/bot/vikingbot/channels/telegram.py+++ b/bot/vikingbot/channels/telegram.py@@ -263,6 +263,7 @@ class TelegramChannel(BaseChannel):returnawait self._handle_message(sender_id=str(update.effective_user.id),+ sender_name=update.effective_user.full_name or str(update.effective_user.id),chat_id=str(update.message.chat_id),content=update.message.text,)@@ -363,6 +364,7 @@ class TelegramChannel(BaseChannel):# Forward to the message busawait self._handle_message(sender_id=sender_id,+ sender_name=user.full_name or sender_id,chat_id=str_chat_id,content=content,media=media_paths,diff --git a/bot/vikingbot/channels/whatsapp.py b/bot/vikingbot/channels/whatsapp.pyindex 23794a88f..369ef09d4 100644--- a/bot/vikingbot/channels/whatsapp.py+++ b/bot/vikingbot/channels/whatsapp.py@@ -125,6 +125,7 @@ class WhatsAppChannel(BaseChannel):await self._handle_message(sender_id=sender_id,+ sender_name=data.get("pushName") or sender_id,chat_id=sender, # Use full LID for repliescontent=content,metadata={