diff --git a/ga.py b/ga.py index b2a21df2..d84d52ce 100644 --- a/ga.py +++ b/ga.py @@ -580,7 +580,7 @@ class GenericAgentHandler(BaseHandler): 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 b9077f5d..3b0e6b06 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)