From 2d753a69308c3c34b0945c5c272d24d0a65424bf Mon Sep 17 00:00:00 2001 From: Liang Jiaqing Date: Sun, 19 Apr 2026 17:15:38 +0800 Subject: [PATCH] improve /resume: use regex to extract history blocks instead of naive tail reading --- agentmain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agentmain.py b/agentmain.py index 4643d3c..2faf70d 100644 --- a/agentmain.py +++ b/agentmain.py @@ -109,7 +109,7 @@ class GeneraticAgent: display_queue.put({'done': smart_format(f"✅ session.{k} = {repr(v)}", max_str_len=500), 'source': 'system'}) return None if raw_query.strip() == '/resume': - return '简单看看model_responses中的最近几次对话结尾部分(除了本次),分别简单总结一下让我选择,然后你简单阅读了解情况后作为我们接下来聊天的基础' + return r'用re.findall(r"\\n\[(?:USER\|Agent)\].*?", content, re.DOTALL) 扫temp/model_responses/下各文件(除本PID),取每文件最后一个匹配(注意JSON里换行是字面\\n)作为该会话内容,按mtime倒序,每个用一句话总结聊了什么让我选择;选定后再简单读该文件末尾作为聊天基础' return raw_query def run(self):