From f853fb47a1d6455277bbe2b8f2bce32b5f9e7042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=9C=8B?= Date: Wed, 14 Oct 2026 13:20:17 +0800 Subject: [PATCH] fix(ga): fold periodic global_memory re-injection like (#832) --- ga.py | 2 +- llmcore.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ga.py b/ga.py index b2a21df24..d84d52ce7 100644 --- a/ga.py +++ b/ga.py @@ -580,7 +580,7 @@ def turn_end_callback(self, response, tool_calls, tool_results, turn, next_promp next_prompt += f"\n\n[DANGER] Turn {turn}. Call update_working_checkpoint to save key context. Stop ineffective retries; if no progress, switch strategy: 1) Probe physical boundaries 2) **Re-read relevant SOPs**" elif turn % 31 == 0: next_prompt += f"\n\n[DANGER] Turn {turn}. Write checkpoints/key findings/tried approaches to a **file** for future reference (not only working_checkpoint!). Avoid losing critical info." - elif turn % 10 == 0: next_prompt += get_global_memory() + elif turn % 10 == 0: next_prompt += f'{get_global_memory()}' if _plan and turn >= 10 and turn % 5 == 0: next_prompt = f"[Plan Hint] 正在计划模式。必须 file_read({_plan}) 确认当前步骤,回复开头引用:📌 当前步骤:...\n\n" + next_prompt diff --git a/llmcore.py b/llmcore.py index b9077f5df..3b0e6b060 100644 --- a/llmcore.py +++ b/llmcore.py @@ -52,7 +52,7 @@ def compress_history_tags(messages, keep_recent=10, max_len=800, force=False, in if compress_history_tags._cd % interval != 0: return messages _before = sum(len(json.dumps(m, ensure_ascii=False)) for m in messages) _pats = {tag: re.compile(rf'(<{tag}>)([\s\S]*?)()') for tag in ('thinking', 'think', 'tool_use', 'tool_result')} - _hist_pat = re.compile(r'<(history|key_info|earlier_context)>[\s\S]*?') + _hist_pat = re.compile(r'<(history|key_info|earlier_context|global_memory)>[\s\S]*?') def _trunc_str(s): return s[:max_len//2] + '\n...[Truncated]...\n' + s[-max_len//2:] if isinstance(s, str) and len(s) > max_len else s def _trunc(text): text = _hist_pat.sub(lambda m: f'<{m.group(1)}>[...]', text)