diff --git a/reme/agent/chat/fs_cli.py b/reme/agent/chat/fs_cli.py index 953f4f59..19640fe9 100644 --- a/reme/agent/chat/fs_cli.py +++ b/reme/agent/chat/fs_cli.py @@ -6,6 +6,7 @@ from pathlib import Path from ...core.enumeration import Role, ChunkEnum from ...core.op import BaseReactStream from ...core.schema import Message, StreamChunk +from ...tool.fs import BashTool, LsTool, ReadTool, WriteTool, EditTool class FsCli(BaseReactStream): @@ -52,7 +53,17 @@ class FsCli(BaseReactStream): # Summarize current conversation and save to memory files current_date = datetime.now().strftime("%Y-%m-%d") - summarizer = FsSummarizer(tools=self.tools, working_dir=self.working_dir) + summarizer = FsSummarizer( + tools=[ + BashTool(cwd=self.working_dir), + LsTool(cwd=self.working_dir), + ReadTool(cwd=self.working_dir), + WriteTool(cwd=self.working_dir), + EditTool(cwd=self.working_dir), + ], + working_dir=self.working_dir, + language=self.language, + ) result = await summarizer.call( messages=self.messages, @@ -113,7 +124,7 @@ class FsCli(BaseReactStream): left_messages = cut_result.get("left_messages", []) # Step 2: Generate summary via Compactor - compactor = FsCompactor() + compactor = FsCompactor(language=self.language) summary_content = await compactor.call( messages_to_summarize=messages_to_summarize, turn_prefix_messages=turn_prefix_messages, diff --git a/reme/agent/fs/fs_summarizer.py b/reme/agent/fs/fs_summarizer.py index d85e2c2a..d1406462 100644 --- a/reme/agent/fs/fs_summarizer.py +++ b/reme/agent/fs/fs_summarizer.py @@ -13,8 +13,9 @@ from ...core.utils import format_messages class FsSummarizer(BaseReact): """Retrieve personal memories through vector search and history reading.""" - def __init__(self, memory_dir: str = "memory", version: str = "default", **kwargs): + def __init__(self, working_dir: str, memory_dir: str = "memory", version: str = "default", **kwargs): super().__init__(**kwargs) + self.working_dir: str = working_dir self.memory_dir: str = memory_dir self.version: str = version @@ -29,6 +30,7 @@ class FsSummarizer(BaseReact): content=self.prompt_format( "user_message_default", conversation=format_messages(messages, add_index=False), + working_dir=self.working_dir, date=date_str, memory_dir=self.memory_dir, ), diff --git a/reme/agent/fs/fs_summarizer.yaml b/reme/agent/fs/fs_summarizer.yaml index dde01f80..477a79e8 100644 --- a/reme/agent/fs/fs_summarizer.yaml +++ b/reme/agent/fs/fs_summarizer.yaml @@ -10,24 +10,78 @@ user_message: | If nothing to store, reply with [SILENT]. user_message_default: | + Pre-compaction memory flush turn. + The session is near auto-compaction; capture durable memories to disk. + + Current Date: {date} + Working Dir: {working_dir} + + Store durable memories now (use {memory_dir}/YYYY-MM-DD.md). + + Workflow: + 1. Use read_tool to read {memory_dir}/YYYY-MM-DD.md (if file doesn't exist, read_tool tool will return an error) + 2. Intelligently merge new information with existing content (skip if file doesn't exist): + - Avoid duplicating information that's already recorded + - Enrich existing entries with new details when relevant + - Maintain chronological order when applicable + 3. Write the updated content: + - Use edit_tool to update specific sections when possible + - Use write_tool to overwrite the entire file if major restructuring is needed + 4. Create {memory_dir}/ if it doesn't exist + + Principles: + - Always preserve timestamps, dates, and time-related context + - Only add truly new or enriching information + - Keep entries concise but complete + - If nothing meaningful to store, reply with [SILENT] + + +user_message_default_zh: | + 预压缩内存刷新轮次。 + 当前会话即将进入自动压缩阶段;请将持久化记忆捕获并写入磁盘。 + + 当前日期:{date} + 工作目录:{working_dir} + + 立即存储持久化记忆(使用路径 {memory_dir}/YYYY-MM-DD.md)。 + + 工作流程: + 1. 使用 read_tool 读取 {memory_dir}/YYYY-MM-DD.md(如文件不存在,read_tool 会返回错误提示) + 2. 智能合并新信息与现有内容(若文件不存在则跳过合并): + - 避免重复已记录的信息 + - 在相关时丰富现有条目的新细节 + - 在适用时保持时间顺序 + 3. 写入更新后的内容: + - 尽可能使用 edit_tool 更新特定部分 + - 如需大幅重构则使用 write_tool 覆盖整个文件 + 4. 如 {memory_dir}/ 不存在则创建 + + 原则: + - 始终保留时间戳、日期和时间相关上下文 + - 仅添加真正新的或有丰富价值的信息 + - 保持条目简洁但完整 + - 若无有意义的内容可存储,请回复 [SILENT] + + +user_message_v1: | {conversation} The conversation is about to be compacted. Please extract persistent memories to disk. Current Date: {date} + Working Dir: {working_dir} Execution Flow: 1. Determine if the conversation contains information worth storing - If no: Reply with reason + [SILENT] - If yes: Continue to step 2 - 2. Check file {memory_dir}/YYYY-MM-DD.md (use actual date) - - File doesn't exist: Write new memories directly - - File exists: - a) Read existing content - b) Compare and identify new/updated information - c) Prefer edit_tool for precise additions (preserves existing content); write_tool overwrites entire file + 2. Use Read tool to read {memory_dir}/YYYY-MM-DD.md (use actual date) + - If file doesn't exist (Read returns error): Write new memories directly + - If file exists: + a) Compare and identify new/updated information from the read content + c) Prefer `edit_tool` for precise additions (preserves existing content); `write_tool` overwrites entire file d) If no new information: Reply with explanation + [SILENT] Update Principles: @@ -41,25 +95,25 @@ user_message_default: | Please store persistent memories, keeping entries concise and well-structured. -user_message_default_zh: | +user_message_v1_zh: | {conversation} conversation即将压缩,请提取持久性记忆存储至磁盘。 当前日期:{date} + 工作目录: {working_dir} 执行流程: 1. 判断对话是否包含值得存储的信息 - 若无:回复原因 + [SILENT] - 若有:继续步骤 2 - 2. 检查文件 {memory_dir}/YYYY-MM-DD.md(使用实际日期) - - 文件不存在:直接写入新记忆 + 2. 使用 Read 工具读取 {memory_dir}/YYYY-MM-DD.md(使用实际日期) + - 文件不存在(Read 返回错误):直接使用 `write_tool` 写入新记忆 - 文件已存在: - a) 读取现有内容 - b) 对比识别新增/更新信息 - c) 优先使用 edit_tool 精准添加新信息(保留已有内容),write_tool 会覆盖整个文件 + a) 从读取的内容中对比识别新增/更新信息 + c) 优先使用 `edit_tool` 精准添加新信息(保留已有内容) d) 若无新信息:回复说明 + [SILENT] 更新原则: diff --git a/reme/config/default.yaml b/reme/config/default.yaml index 1d4dd742..3a7e7073 100644 --- a/reme/config/default.yaml +++ b/reme/config/default.yaml @@ -20,8 +20,7 @@ flows: llms: default: backend: openai -# model_name: qwen3-30b-a3b-instruct-2507 - model_name: qwen3-next-80b-a3b-thinking + model_name: qwen3-30b-a3b-instruct-2507 # model_name: qwen3-30b-a3b-thinking-2507 request_interval: 1 # temperature: 0.0001 diff --git a/reme/config/fs.yaml b/reme/config/fs.yaml index 7c4be922..2bcf0516 100644 --- a/reme/config/fs.yaml +++ b/reme/config/fs.yaml @@ -4,7 +4,8 @@ llms: default: backend: openai # model_name: qwen3-30b-a3b-instruct-2507 - model_name: qwen3-30b-a3b-thinking-2507 +# model_name: qwen3-30b-a3b-thinking-2507 + model_name: qwen3-235b-a22b-thinking-2507 request_interval: 1 # temperature: 0.0001