mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-09-20 08:58:15 +00:00
feat: 添加 context_rewrite 工具并清理工具限制器死配置
- 新增 context_rewrite 工具:允许 AI 在单轮内压缩工具调用上下文
- 清理 persona_query_max 和 task_query_max 死配置(commit 9be60ba 引入)
- 同步全栈:后端/前端/文档/测试 18 个文件
- 测试:70/70 通过
This commit is contained in:
@ -50,6 +50,10 @@ def execute_tool(graph: Any, tool_name: str, arguments: dict) -> str:
|
||||
result = graph.cleanup(dry_run=arguments.get("dry_run", True))
|
||||
return json.dumps(result, ensure_ascii=False, default=str)
|
||||
|
||||
elif tool_name == "context_rewrite":
|
||||
result = execute_context_rewrite(graph, arguments)
|
||||
return json.dumps(result, ensure_ascii=False, default=str)
|
||||
|
||||
# 人设图管理工具
|
||||
elif tool_name == "persona_update":
|
||||
result = execute_persona_update(graph, arguments)
|
||||
@ -111,6 +115,24 @@ def format_recall_result(result: dict) -> str:
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def execute_context_rewrite(graph: Any, arguments: dict) -> dict:
|
||||
"""压缩工具调用上下文"""
|
||||
summary = arguments.get("summary", "")
|
||||
|
||||
# 验证格式:必须包含工具调用标记
|
||||
if "[工具调用总结" not in summary:
|
||||
return {
|
||||
"status": "error",
|
||||
"message": "总结格式错误:必须包含 [工具调用总结: 本次总结了 N 次工具调用 | 调用工具: ...] 标记"
|
||||
}
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "上下文已压缩",
|
||||
"summary": summary
|
||||
}
|
||||
|
||||
|
||||
# 人设图管理工具实现
|
||||
def execute_persona_update(graph: Any, arguments: dict) -> dict:
|
||||
"""更新人设"""
|
||||
|
||||
Reference in New Issue
Block a user