diff --git a/src/common/data_models/message_manager_data_model.py b/src/common/data_models/message_manager_data_model.py index a3f348898..4b9ba7d5e 100644 --- a/src/common/data_models/message_manager_data_model.py +++ b/src/common/data_models/message_manager_data_model.py @@ -162,17 +162,17 @@ class StreamContext(BaseDataModel): "stream_id": self.stream_id, } await unified_manager.add_message(message_dict) - logger.debug(f"��Ϣ�����ӵ��������ϵͳ: {message.message_id}") + logger.debug(f"消息已添加到统一记忆系统: {message.message_id}") except Exception as e: - logger.error(f"������Ϣ���������ϵͳʧ��: {e}") + logger.error(f"添加消息到统一记忆系统失败: {e}") return True except Exception as e: - logger.error(f"������Ϣ������������ʧ�� {self.stream_id}: {e}") + logger.error(f"添加消息到上下文失败 {self.stream_id}: {e}") return False async def update_message(self, message_id: str, updates: dict[str, Any]) -> bool: - """�����������е���Ϣ""" + """更新上下文中的消息信息""" try: for message in self.unread_messages: if str(message.message_id) == str(message_id): @@ -194,10 +194,10 @@ class StreamContext(BaseDataModel): message.should_reply = updates["should_reply"] break - logger.debug(f"���µ�����������Ϣ: {self.stream_id}/{message_id}") + logger.debug(f"更新消息信息: {self.stream_id}/{message_id}") return True except Exception as e: - logger.error(f"���µ�����������Ϣʧ�� {self.stream_id}/{message_id}: {e}") + logger.error(f"更新消息信息失败 {self.stream_id}/{message_id}: {e}") return False def add_action_to_message(self, message_id: str, action: str): diff --git a/src/common/database/api/crud.py b/src/common/database/api/crud.py index 1c9b1aef9..ea172df1c 100644 --- a/src/common/database/api/crud.py +++ b/src/common/database/api/crud.py @@ -149,7 +149,6 @@ class CRUDBase: cache = await get_cache() cached_dict = await cache.get(cache_key) if cached_dict is not None: - logger.debug(f"缓存命中: {cache_key}") # 从字典恢复对象 return _dict_to_model(self.model, cached_dict) @@ -194,7 +193,6 @@ class CRUDBase: cache = await get_cache() cached_dict = await cache.get(cache_key) if cached_dict is not None: - logger.debug(f"缓存命中: {cache_key}") # 从字典恢复对象 return _dict_to_model(self.model, cached_dict) @@ -247,7 +245,6 @@ class CRUDBase: cache = await get_cache() cached_dicts = await cache.get(cache_key) if cached_dicts is not None: - logger.debug(f"缓存命中: {cache_key}") # 从字典列表恢复对象列表 return [_dict_to_model(self.model, d) for d in cached_dicts] diff --git a/src/common/database/api/query.py b/src/common/database/api/query.py index 6815820ef..fb2212e28 100644 --- a/src/common/database/api/query.py +++ b/src/common/database/api/query.py @@ -199,7 +199,6 @@ class QueryBuilder(Generic[T]): cache = await get_cache() cached_dicts = await cache.get(cache_key) if cached_dicts is not None: - logger.debug(f"缓存命中: {cache_key}") dict_rows = [dict(row) for row in cached_dicts] if as_dict: return dict_rows @@ -238,7 +237,6 @@ class QueryBuilder(Generic[T]): cache = await get_cache() cached_dict = await cache.get(cache_key) if cached_dict is not None: - logger.debug(f"缓存命中: {cache_key}") row = dict(cached_dict) if as_dict: return row @@ -277,7 +275,6 @@ class QueryBuilder(Generic[T]): cache = await get_cache() cached = await cache.get(cache_key) if cached is not None: - logger.debug(f"缓存命中: {cache_key}") return cached # 构建count查询 diff --git a/src/common/database/utils/decorators.py b/src/common/database/utils/decorators.py index 319debcb1..7a7fe219e 100644 --- a/src/common/database/utils/decorators.py +++ b/src/common/database/utils/decorators.py @@ -192,7 +192,6 @@ def cached( cached_result = await cache.get(cache_key) if cached_result is not None: - logger.debug(f"缓存命中: {cache_key}") return cached_result # 执行函数 diff --git a/src/plugins/built_in/affinity_flow_chatter/planner/plan_filter.py b/src/plugins/built_in/affinity_flow_chatter/planner/plan_filter.py index 4c9d7cf76..d13fbe2a3 100644 --- a/src/plugins/built_in/affinity_flow_chatter/planner/plan_filter.py +++ b/src/plugins/built_in/affinity_flow_chatter/planner/plan_filter.py @@ -663,6 +663,18 @@ class ChatterPlanFilter: f"[{action}] 找不到目标消息,target_message_id: {action_data.get('target_message_id')}" ) + # reply 动作必须有目标消息,如果仍然为 None,则使用最新消息 + if action in ["reply", "proactive_reply"] and action_message_obj is None: + logger.warning(f"[{action}] 目标消息为空,强制使用最新消息作为兜底") + latest_message_dict = self._get_latest_message(message_id_list) + if latest_message_dict: + from src.common.data_models.database_data_model import DatabaseMessages + try: + action_message_obj = DatabaseMessages(**latest_message_dict) + logger.info(f"[{action}] 成功使用最新消息: {action_message_obj.message_id}") + except Exception as e: + logger.error(f"[{action}] 无法转换最新消息: {e}") + return ActionPlannerInfo( action_type=action, reasoning=reasoning,