zai-org / zai-org/feedback

[Bug] cli/exec 无输出上限或自动清理,单次 ugrep 警告可产生 5 GiB 日志并累计占用 45.77 GiB

Open
#474 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2 status: 待评估 type: Bug
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

提交前确认 · Pre-submission checklist
  • 我已搜索过现有 issue,确认这不是重复 / I searched existing issues and confirmed this isn't a duplicate.
  • 我已阅读 CONTRIBUTING.md / I've read CONTRIBUTING.md.
问题类别 · Category

性能 · Performance

涉及的 Agent 框架 · Agent framework

ZCode Agent(自研)

严重程度 · Severity

影响体验 · Major (功能可用但体验受损 / works but degraded)

复现频率 · Reproducibility

偶现 · Sometimes

问题描述 · Description

ZCode 的 %USERPROFILE%\.zcode\cli\exec 会完整保留历史命令的 stdout,缺少单次输出大小上限、日志轮转和总容量清理机制。在一次异常刷屏后,本机的 .zcode 目录累计占用 50.77 GiB,其中 cli\exec 占用 45.77 GiB

现场统计:

  • .zcode 总计:50.77 GiB
  • cli\exec:45.77 GiB,共 1022 个文件
  • 几乎全部空间来自 *-stdout.log
  • 56 个日志文件超过 100 MiB
  • 最大单个 stdout 日志约 5 GiB
  • stderr 日志占用可忽略

抽样检查最大日志的开头和结尾,内容均为 ugrep 在递归遍历嵌套的 node_modules 路径时反复输出的 “No such file or directory” 警告。路径表现为依赖目录不断重复嵌套,疑似搜索过程跟随了 junction/symlink 或依赖链接形成的循环。

官方 FAQ 已说明 ~/.zcode/cli/exec “currently never cleaned up automatically”,因此即使异常命令已经结束,历史输出仍会永久占用磁盘。普通用户通常无法察觉,直到系统盘空间显著减少。

复现步骤 · Steps to reproduce
  1. 在包含大量链接依赖或嵌套 node_modules 的大型 workspace 中使用 ZCode Agent。
  2. 让 Agent 执行一次全局递归搜索;现场中 ZCode 调用了 ugrep
  3. 搜索过程中出现大量针对重复嵌套依赖路径的 “No such file or directory” 警告。
  4. 命令结束后检查 %USERPROFILE%\.zcode\cli\exec\<SESSION>\<CALL>-stdout.log
  5. 可以看到 stdout 被无上限地写入单个日志文件;后续会话继续累积,旧日志不会自动回收。
期望表现 · Expected behavior
  1. 单次命令的落盘输出应有安全上限;达到上限后截断,并在 UI 和日志中保留明确的截断提示。
  2. cli/exec 应支持按时间或总容量自动清理,例如保留近期任务并用 LRU 淘汰旧输出。
  3. 当单个日志或整个目录异常增长时,应向用户显示磁盘占用告警。
  4. 内置搜索工具应避免递归跟随 junction/symlink 环,或默认排除 node_modules 等依赖目录。
实际表现 · Actual behavior

stdout 会持续完整写入磁盘,没有观察到单文件大小限制;命令结束后日志长期保留,目录总量可以增长到数十 GiB。最大单文件达到约 5 GiB,cli/exec 最终占用 45.77 GiB。

虽然退出 ZCode 后可以手工删除该目录,但这只能临时释放空间,不能防止后续异常输出再次填满系统盘。

ZCode 版本 · ZCode version

3.10.2.6414

设备 / 系统 / 浏览器 · Device / OS / Browser

WINDOWS 10 PRO 25H2 OS BUILD 26200 9168 ZCODE DESKTOP

截图 / 录屏 / 日志 · Screenshots / Recordings / Logs

为避免公开本机用户名、项目结构、会话 ID 和大体积日志,此处只提供脱敏后的代表性片段:

ugrep: warning: cannot open directory <WORKSPACE>\packages\...\node_modules\...\node_modules\...: No such file or directory
ugrep: warning: cannot read <WORKSPACE>\packages\...\node_modules\...\typescript\lib\*.d.ts: No such file or directory

如维护者需要,可以进一步提供脱敏后的目录统计或小规模日志样本;不会上传数 GiB 的原始 stdout 文件。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the cli/exec output-handling path described in the issue and compare it with the FAQ statement that it is never cleaned automatically. Define completion around bounded stdout files with a visible truncation notice, automatic cleanup of old or oversized output, and protection against unbounded directory growth; the report provides no test file or code entry point.

Written by the indexing model from the issue text.

Assessment

Domain
cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.