chore: self-commit core logic updates and agent state
This commit is contained in:
18
ga.py
18
ga.py
@@ -396,13 +396,13 @@ class GenericAgentHandler(BaseHandler):
|
||||
'''Agent觉得当前任务完成后有重要信息需要记忆时调用此工具。
|
||||
目前只支持全局记忆,暂不处理过程记忆或特定任务经验。
|
||||
'''
|
||||
next_prompt = '''### [总结提炼经验] 既然你觉得当前任务有重要信息需要记忆,请提取最近一次任务中【事实验证成功且长期有效】的环境事实与用户偏好,更新至全局记忆。
|
||||
prompt = '''### [总结提炼经验] 既然你觉得当前任务有重要信息需要记忆,请提取最近一次任务中【事实验证成功且长期有效】的环境事实与用户偏好,更新至全局记忆。
|
||||
1. 严禁记录任何任务特定中间执行过程或临时变量经验,那是过程记忆不是全局记忆。
|
||||
2. 若无高价值新事实,那就不更新任何内容。
|
||||
3. 尽量先查看现有全局记忆形式,仅作少量修改不要影响其余部分。insight也要同步更新全局记忆的短印象来提醒存在性。
|
||||
4. 优先使用file_read和file_patch来保证少量修改。'''
|
||||
4. 优先使用file_read和file_patch来保证少量修改。''' + get_global_memory()
|
||||
yield "[Info] Start distilling good memory for long-term storage.\n"
|
||||
return StepOutcome({"status": "success"}, next_prompt=next_prompt)
|
||||
return StepOutcome({"status": "success"}, next_prompt=prompt)
|
||||
|
||||
def _get_anchor_prompt(self):
|
||||
h_str = "\n".join(self.history_info[-20:])
|
||||
@@ -411,3 +411,15 @@ class GenericAgentHandler(BaseHandler):
|
||||
if self.plan: prompt += f"\n<plan>{self.plan}</plan>"
|
||||
if self.focus: prompt += f"\n<focus>{self.focus}</focus>"
|
||||
return prompt + "\n请继续执行下一步。"
|
||||
|
||||
def get_global_memory():
|
||||
prompt = "\n"
|
||||
try:
|
||||
with open('memory/global_mem_insight.txt', 'r', encoding='utf-8') as f: insight = f.read()
|
||||
prompt += f"\n\n[Global Memory Insight]\n"
|
||||
prompt += 'IMPORTANT PATHS: ../memory/global_mem.txt (Facts), ../memory/global_mem_insight.txt (Logic), ../ (Your Code Root).\n'
|
||||
prompt += 'MEM_RULE: Insight is the index of Facts. Sync Insight whenever Facts change. For details, read Facts.\n'
|
||||
prompt += "EXT: ../memory/ may contain other task-specific memories.\n"
|
||||
prompt += insight + "\n"
|
||||
except FileNotFoundError: pass
|
||||
return prompt
|
||||
Reference in New Issue
Block a user