fix:修复reply导致的异常空跳
This commit is contained in:
@@ -438,94 +438,4 @@ class ActionModifier:
|
||||
return True
|
||||
else:
|
||||
logger.debug(f"{self.log_prefix}动作 {action_name} 未匹配到任何关键词: {activation_keywords}")
|
||||
return False
|
||||
|
||||
# async def analyze_loop_actions(self, history_loop: List[CycleDetail]) -> List[tuple[str, str]]:
|
||||
# """分析最近的循环内容并决定动作的移除
|
||||
|
||||
# Returns:
|
||||
# List[Tuple[str, str]]: 包含要删除的动作及原因的元组列表
|
||||
# [("action3", "some reason")]
|
||||
# """
|
||||
# removals = []
|
||||
|
||||
# # 获取最近10次循环
|
||||
# recent_cycles = history_loop[-10:] if len(history_loop) > 10 else history_loop
|
||||
# if not recent_cycles:
|
||||
# return removals
|
||||
|
||||
# reply_sequence = [] # 记录最近的动作序列
|
||||
|
||||
# for cycle in recent_cycles:
|
||||
# action_result = cycle.loop_plan_info.get("action_result", {})
|
||||
# action_type = action_result.get("action_type", "unknown")
|
||||
# reply_sequence.append(action_type == "reply")
|
||||
|
||||
# # 计算连续回复的相关阈值
|
||||
|
||||
# max_reply_num = int(global_config.focus_chat.consecutive_replies * 3.2)
|
||||
# sec_thres_reply_num = int(global_config.focus_chat.consecutive_replies * 2)
|
||||
# one_thres_reply_num = int(global_config.focus_chat.consecutive_replies * 1.5)
|
||||
|
||||
# # 获取最近max_reply_num次的reply状态
|
||||
# if len(reply_sequence) >= max_reply_num:
|
||||
# last_max_reply_num = reply_sequence[-max_reply_num:]
|
||||
# else:
|
||||
# last_max_reply_num = reply_sequence[:]
|
||||
|
||||
# # 详细打印阈值和序列信息,便于调试
|
||||
# logger.info(
|
||||
# f"连续回复阈值: max={max_reply_num}, sec={sec_thres_reply_num}, one={one_thres_reply_num},"
|
||||
# f"最近reply序列: {last_max_reply_num}"
|
||||
# )
|
||||
# # print(f"consecutive_replies: {consecutive_replies}")
|
||||
|
||||
# # 根据最近的reply情况决定是否移除reply动作
|
||||
# if len(last_max_reply_num) >= max_reply_num and all(last_max_reply_num):
|
||||
# # 如果最近max_reply_num次都是reply,直接移除
|
||||
# reason = f"连续回复过多(最近{len(last_max_reply_num)}次全是reply,超过阈值{max_reply_num})"
|
||||
# removals.append(("reply", reason))
|
||||
# # reply_count = len(last_max_reply_num) - no_reply_count
|
||||
# elif len(last_max_reply_num) >= sec_thres_reply_num and all(last_max_reply_num[-sec_thres_reply_num:]):
|
||||
# # 如果最近sec_thres_reply_num次都是reply,40%概率移除
|
||||
# removal_probability = 0.4 / global_config.focus_chat.consecutive_replies
|
||||
# if random.random() < removal_probability:
|
||||
# reason = (
|
||||
# f"连续回复较多(最近{sec_thres_reply_num}次全是reply,{removal_probability:.2f}概率移除,触发移除)"
|
||||
# )
|
||||
# removals.append(("reply", reason))
|
||||
# elif len(last_max_reply_num) >= one_thres_reply_num and all(last_max_reply_num[-one_thres_reply_num:]):
|
||||
# # 如果最近one_thres_reply_num次都是reply,20%概率移除
|
||||
# removal_probability = 0.2 / global_config.focus_chat.consecutive_replies
|
||||
# if random.random() < removal_probability:
|
||||
# reason = (
|
||||
# f"连续回复检测(最近{one_thres_reply_num}次全是reply,{removal_probability:.2f}概率移除,触发移除)"
|
||||
# )
|
||||
# removals.append(("reply", reason))
|
||||
# else:
|
||||
# logger.debug(f"{self.log_prefix}连续回复检测:无需移除reply动作,最近回复模式正常")
|
||||
|
||||
# return removals
|
||||
|
||||
# def get_available_actions_count(self, mode: str = "focus") -> int:
|
||||
# """获取当前可用动作数量(排除默认的no_action)"""
|
||||
# current_actions = self.action_manager.get_using_actions_for_mode(mode)
|
||||
# # 排除no_action(如果存在)
|
||||
# filtered_actions = {k: v for k, v in current_actions.items() if k != "no_action"}
|
||||
# return len(filtered_actions)
|
||||
|
||||
# def should_skip_planning_for_no_reply(self) -> bool:
|
||||
# """判断是否应该跳过规划过程"""
|
||||
# current_actions = self.action_manager.get_using_actions_for_mode("focus")
|
||||
# # 排除no_action(如果存在)
|
||||
# if len(current_actions) == 1 and "no_reply" in current_actions:
|
||||
# return True
|
||||
# return False
|
||||
|
||||
# def should_skip_planning_for_no_action(self) -> bool:
|
||||
# """判断是否应该跳过规划过程"""
|
||||
# available_count = self.action_manager.get_using_actions_for_mode("normal")
|
||||
# if available_count == 0:
|
||||
# logger.debug(f"{self.log_prefix} 没有可用动作,跳过规划")
|
||||
# return True
|
||||
# return False
|
||||
return False
|
||||
Reference in New Issue
Block a user