Update core scripts and tools schema

This commit is contained in:
Jiaqing Liang
2026-02-09 14:55:41 +08:00
parent 3f1fad8ab9
commit 61daedec3f
4 changed files with 4 additions and 3 deletions

View File

@@ -45,6 +45,7 @@ def agent_runner_loop(client, system_prompt, user_input, handler, tools_schema,
] ]
for turn in range(max_turns): for turn in range(max_turns):
yield f"**LLM Running (Turn {turn+1}) ...**\n\n" 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_gen = client.chat(messages=messages, tools=tools_schema)
response = yield from response_gen response = yield from response_gen
yield '\n\n' yield '\n\n'

View File

@@ -61,7 +61,7 @@
"candidates": {"type": "array", "items": {"type": "string"}, "description": "提供给用户的可选快捷选项列表。"}}, "required": ["question"]} "candidates": {"type": "array", "items": {"type": "string"}, "description": "提供给用户的可选快捷选项列表。"}}, "required": ["question"]}
}}, }},
{"type": "function", "function": { {"type": "function", "function": {
"name": "conclude_and_reflect", "name": "trigger_memory_update",
"description": "用户的任务完成后,若发现值得长期记忆的信息(环境事实/用户偏好/避坑经验),调用此工具触发记忆提炼。不允许在记忆更新或自主流程内调用。", "description": "用户的任务完成后,若发现值得长期记忆的信息(环境事实/用户偏好/避坑经验),调用此工具触发记忆提炼。不允许在记忆更新或自主流程内调用。",
"parameters": {"type": "object", "properties": {}}} "parameters": {"type": "object", "properties": {}}}
} }

2
ga.py
View File

@@ -438,7 +438,7 @@ class GenericAgentHandler(BaseHandler):
yield "[Info] Final response to user.\n" yield "[Info] Final response to user.\n"
return StepOutcome(response, next_prompt=None, should_exit=True) 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觉得当前任务完成后有重要信息需要记忆时调用此工具。 '''Agent觉得当前任务完成后有重要信息需要记忆时调用此工具。
''' '''
prompt = '''### [总结提炼经验] 既然你觉得当前任务有重要信息需要记忆,请提取最近一次任务中【事实验证成功且长期有效】的环境事实、用户偏好、重要步骤,更新记忆。 prompt = '''### [总结提炼经验] 既然你觉得当前任务有重要信息需要记忆,请提取最近一次任务中【事实验证成功且长期有效】的环境事实、用户偏好、重要步骤,更新记忆。

View File

@@ -226,7 +226,7 @@ class ToolClient:
prompt += f"=== {role} ===\n{m['content']}\n\n" prompt += f"=== {role} ===\n{m['content']}\n\n"
self.total_cd_tokens += len(m['content']) 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" prompt += "=== ASSISTANT ===\n"
return prompt return prompt