From 61daedec3f7cffbe745f44e514410bc2e4458b64 Mon Sep 17 00:00:00 2001 From: Jiaqing Liang Date: Mon, 9 Feb 2026 14:55:41 +0800 Subject: [PATCH] Update core scripts and tools schema --- agent_loop.py | 1 + assets/tools_schema.json | 2 +- ga.py | 2 +- sidercall.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/agent_loop.py b/agent_loop.py index 49335c9..8516c48 100644 --- a/agent_loop.py +++ b/agent_loop.py @@ -45,6 +45,7 @@ def agent_runner_loop(client, system_prompt, user_input, handler, tools_schema, ] for turn in range(max_turns): yield f"**LLM Running (Turn {turn+1}) ...**\n\n" + if (turn+1) % 10 == 0: client.last_tools = '' # 每10轮重置一次工具描述,避免上下文过大导致的模型性能下降 response_gen = client.chat(messages=messages, tools=tools_schema) response = yield from response_gen yield '\n\n' diff --git a/assets/tools_schema.json b/assets/tools_schema.json index b86f07f..c52288b 100644 --- a/assets/tools_schema.json +++ b/assets/tools_schema.json @@ -61,7 +61,7 @@ "candidates": {"type": "array", "items": {"type": "string"}, "description": "提供给用户的可选快捷选项列表。"}}, "required": ["question"]} }}, {"type": "function", "function": { - "name": "conclude_and_reflect", + "name": "trigger_memory_update", "description": "用户的任务完成后,若发现值得长期记忆的信息(环境事实/用户偏好/避坑经验),调用此工具触发记忆提炼。不允许在记忆更新或自主流程内调用。", "parameters": {"type": "object", "properties": {}}} } diff --git a/ga.py b/ga.py index 3a9ee0f..2db9bd5 100644 --- a/ga.py +++ b/ga.py @@ -438,7 +438,7 @@ class GenericAgentHandler(BaseHandler): yield "[Info] Final response to user.\n" return StepOutcome(response, next_prompt=None, should_exit=True) - def do_conclude_and_reflect(self, args, response): + def do_trigger_memory_update(self, args, response): '''Agent觉得当前任务完成后有重要信息需要记忆时调用此工具。 ''' prompt = '''### [总结提炼经验] 既然你觉得当前任务有重要信息需要记忆,请提取最近一次任务中【事实验证成功且长期有效】的环境事实、用户偏好、重要步骤,更新记忆。 diff --git a/sidercall.py b/sidercall.py index 3b9ea35..3512a1c 100644 --- a/sidercall.py +++ b/sidercall.py @@ -226,7 +226,7 @@ class ToolClient: prompt += f"=== {role} ===\n{m['content']}\n\n" self.total_cd_tokens += len(m['content']) - if self.total_cd_tokens > 9000: self.last_tools = '' + if self.total_cd_tokens > 6000: self.last_tools = '' prompt += "=== ASSISTANT ===\n" return prompt