agentscope-ai / agentscope-ai/AgentTeams
缺失标准文件删除机制与 Ignore 规则,导致高频同步占用高 CPU 及“幽灵文件”无限循环 || The standard file deletion mechanism and Ignore rules are missing, resulting in high-frequency synchronization occupying high CPU and infinite loops of "ghost files"
- Lenguaje dominante
- Go
- Estrellas
- 5.6k
- Forks
- 692
- Merge medio
- 5 d 4 h
- PR fusionados (30 d)
- 23
Descripción
当前版本
v1.1.2
普通openclaw manager和 openclaw worker ,非team。
**1. 问题背景 (Context)**
在当前的 Hiclaw 架构中(Controller [含 MinIO] + Manager-Agent + Worker-Agent如 code-detective),当我尝试让 Agent 分析一个完整的前端项目源码时,我不小心将包含海量小文件的 node_modules 目录一起上传到了 MinIO 中。
这触发了一系列严重的连锁反应,最终暴露了系统在文件同步策略和状态生命周期管理上的几个核心缺陷。
**2. 问题复现与现象 (Observed Behavior)**
现象一:高频比对导致 CPU 飙升
由于 node_modules 包含极多小文件,Agent 与 Controller 之间的文件变动高频同步进程(file-sync)消耗了大量 CPU 资源。尝试配置同步排除脚本,但会被系统(Controller 的状态声明)自动覆盖,导致无法通过常规手段忽略该目录。
现象二:陷入“幽灵文件”的无限恢复循环 (The "Ghost File" Loop)
为了拯救 CPU 占用,我试图手动删除这些文件,但陷入了死局:
尝试在 Agent 本地删除:Agent 的同步机制发现本地缺失文件,而 MinIO 中存在,于是触发了 mc mirror 拉取,将文件重新下载回本地。
尝试直接删除 MinIO 中的文件:由于 Controller 容器内维护着一个自己的本地副本(/root/hiclaw-fs/...)且运行着 start-mc-mirror.sh 后台轮询脚本(没有带 --remove 参数),Controller 发现 MinIO 中文件丢失,立刻主动触发 PUT,将本地缓存强行重新上传至 MinIO。
最终的暴力解法:必须同时卡秒删除 Controller 本地缓存 /root/hiclaw-fs/... 和 MinIO 中的目标文件夹,才能彻底打断这个循环。
**3. 根因分析 (Root Cause Analysis)**
我与系统内的 Manager 和 Code-Detective Agent 进行了沟通,并查阅了它们的 SKILL.md,确认了以下底层原因:
缺失标准的文件删除 SOP (No Deletion Mechanism)
当前的 file-sync Skill 仅覆盖了从 MinIO 拉取 (hiclaw-sync) 和向 MinIO 推送的工作流,完全没有定义从 MinIO 删除文件的标准操作指令或 API。这导致“临时工作负担”一旦进入系统,就变成了“永久状态”,Agent 自身无法合法销毁废弃文件。
Controller 的兜底同步策略过于强硬
Controller 容器内的 5 分钟 Fallback 兜底拉取脚本没有处理远程删除的情况。它把自己当成了绝对的数据源(Single Source of Truth),导致任何一方的正当删除行为都会被视作“数据异常丢失”并被强行恢复。
缺乏全局的 Ignore 机制
作为一个代码分析/协同系统,处理 .git、node_modules 或 dist 等构建产物是常态。系统目前缺乏一套标准且不可被覆盖的 .hiclawignore 机制,导致无关文件挤占同步通道。
**4. 改进建议 (Proposed Solutions / Feature Requests)**
建议官方在未来的版本中考虑以下架构优化:
[Feature] 引入标准的 .hiclawignore 机制
允许在项目根目录定义忽略规则,在执行同步或 mc mirror 时自动跳过这些大体积/多碎片的黑洞目录,从根本上解决 CPU 与 IO 瓶颈。
[SOP/API] 完善文件生命周期管理,提供删除接口
在 Agent 的基础 Skill(如 task-management 或 file-sync)中补充标准的文件删除规范。提供明确的 API 或指令,当 Agent 判定任务结束或产生垃圾文件时,能够合法地要求 Controller 从两端(本地和 MinIO)同时抹除数据,而不是用 mc rm 导致状态分裂。
[Bugfix] 修正 Controller 的兜底同步逻辑
重新评估 Controller 作为单一存储网关时的本地缓存行为,如果不承担业务数据持久化职责,应剥离 Controller 挂载业务 workspace 的逻辑;或者在同步脚本中妥善处理 --remove 逻辑,识别并尊重“被删除”这一状态。
如果需要进一步的日志,我会尽量补充。
---
Current version
v1.1.2
Ordinary openclaw manager and openclaw worker, not team.
**1. Problem Background (Context)**
In the current Hiclaw architecture (Controller [including MinIO] + Manager-Agent + Worker-Agent such as code-detective), when I tried to let the Agent analyze the source code of a complete front-end project, I accidentally uploaded the node_modules directory containing a large number of small files to MinIO.
This triggered a series of serious chain reactions, ultimately exposing several core flaws in the system's file synchronization strategy and state lifecycle management.
**2. Problem recurrence and phenomenon (Observed Behavior)**
Phenomenon 1: High-frequency comparison causes CPU to surge
Since node_modules contains many small files, the high-frequency synchronization process (file-sync) of file changes between Agent and Controller consumes a lot of CPU resources. An attempt was made to configure a synchronization exclusion script, but it would be automatically overwritten by the system (Controller's status declaration), making it impossible to ignore the directory through conventional means.
Phenomenon 2: Falling into an infinite recovery loop of "Ghost File" (The "Ghost File" Loop)
To save the CPU usage, I tried to delete these files manually, but got into a dead end:
Try to delete locally on the Agent: The Agent's synchronization mechanism finds that the file is missing locally but exists in MinIO, so it triggers the mc mirror pull and re-downloads the file back to the local.
Try to directly delete the files in MinIO: Since the Controller container maintains a local copy of its own (/root/hiclaw-fs/...) and runs the start-mc-mirror.sh background polling script (without the --remove parameter), the Controller discovers that the files in MinIO are lost and immediately triggers PUT to forcibly re-upload the local cache to MinIO.
The final brute force solution: You must delete the Controller's local cache /root/hiclaw-fs/... and the target folder in MinIO at the same time to completely break this cycle.
**3. Root Cause Analysis**
I communicated with the Manager and Code-Detective Agent in the system and checked their SKILL.md to confirm the following underlying reasons:
Missing standard file deletion SOP (No Deletion Mechanism)
The current file-sync Skill only covers the workflow of pulling from MinIO (hiclaw-sync) and pushing to MinIO, and does not define any standard operating instructions or API for deleting files from MinIO. This results in the "temporary workload" becoming a "permanent state" once it enters the system, and the Agent itself cannot legally destroy discarded files.
Controller’s covert synchronization strategy is too tough
The 5-minute fallback pull script in the Controller container does not handle remote deletion. It regards itself as the absolute source of data (Single Source of Truth), causing any legitimate deletion behavior by any party to be regarded as "abnormal data loss" and be forcibly restored.
Lack of global Ignore mechanism
As a code analysis/collaboration system, handling build artifacts such as .git, node_modules or dist is the norm. The system currently lacks a standard and non-overridable .hiclawignore mechanism, causing irrelevant files to crowd the synchronization channel.
**4. Improvement Suggestions (Proposed Solutions / Feature Requests)**
It is recommended that the official consider the following architectural optimizations in future versions:
[Feature] Introducing the standard .hiclawignore mechanism
Allows you to define ignore rules in the project root directory and automatically skip these large/multi-fragmented black hole directories when performing synchronization or mc mirror, fundamentally solving CPU and IO bottlenecks.
[SOP/API] Improve file life cycle management and provide deletion interface
Supplement standard file deletion specifications in the Agent's base skills (such as task-management or file-sync). Provide clear API or instructions. When the Agent determines that the task is over or a garbage file is generated, it can legally require the Controller to erase data from both ends (local and MinIO) at the same time, instead of using mc rm to cause state split.
[Bugfix] Correct the hidden synchronization logic of Controller
Re-evaluate the local caching behavior of the Controller as a single storage gateway. If it does not assume the responsibility of business data persistence, the logic of the Controller mounting the business workspace should be stripped off; or the --remove logic should be properly handled in the synchronization script to identify and respect the "deleted" status.
If further logs are needed, I'll try to add them.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.