feat(proactive_thinking): 重构主动思考为由Planner直接决策

重构了主动思考的触发和决策流程。原有的通过生成特定prompt来启动思考循环的方式被移除,改为直接调用Planner的`PROACTIVE`模式。

- **Planner增强**:
  - 新增`PROACTIVE`聊天模式,用于处理主动思考场景。
  - 为`PROACTIVE`模式设计了专用的prompt模板,整合了长期记忆、当前状态等信息。
  - 引入`do_nothing`动作,允许Planner在分析后决定保持沉默。
  - 增加从海马体(长期记忆)获取上下文的功能,为决策提供更丰富的背景。

- **ProactiveThinker简化**:
  - 移除了原有的prompt生成和调用`observe`的逻辑。
  - 现在直接调用`action_planner.plan(mode=ChatMode.PROACTIVE)`来获取决策。
  - 根据Planner返回的动作(如`do_nothing`或具体行动),决定是保持沉默还是执行计划。

- **CycleProcessor & Tracker调整**:
  - `CycleProcessor`新增`execute_plan`方法,用于执行一个已经由Planner预先制定好的计划。
  - `CycleTracker`能够区分并标记由主动思考发起的循环(例如,cycle_id为 "1.p"),以便于追踪和分析。
This commit is contained in:
minecraft1024a
2025-08-21 19:29:14 +08:00
parent 15e53742f5
commit 09b36585b3
6 changed files with 191 additions and 116 deletions

View File

@@ -1,5 +1,5 @@
import time
from typing import Optional, Dict, Any
from typing import Optional, Dict, Any, Union
from src.config.config import global_config
from src.common.logger import get_logger
@@ -23,7 +23,7 @@ class CycleDetail:
- 提供序列化和转换功能
"""
def __init__(self, cycle_id: int):
def __init__(self, cycle_id: Union[int, str]):
"""
初始化循环详情记录