zai-org / zai-org/feedback

[Bug] Bash 工具疑似保留已被清理的 cwd,随后持续报 spawn /bin/zsh ENOENT 且当前会话无法恢复

Open
#521 1 comment 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

工具调用 / MCP · Tool use / MCP

涉及的 Agent 框架 · Agent framework

ZCode Agent(自研)

严重程度 · Severity

阻塞使用 · Blocking (无法使用核心功能 / core function unusable)

复现频率 · Reproducibility

仅一次 · Once

问题描述 · Description

macOS 本地项目中,ZCode Agent 的 Bash 工具在一次 Playwright 测试后突然开始持续报错:

spawn /bin/zsh ENOENT

之后在同一 Agent 会话中,无论执行 echotrue、绝对路径 /bin/zsh,还是显式 cd 到仍然存在的项目目录,Bash 都无法恢复。

但同一台 Mac 上:

  • /bin/zsh 文件真实存在;
  • /bin/zsh 可以正常执行;
  • 项目 workspace 目录存在且权限正常;
  • ZCode 内置 Terminal 在同一 workspace 中也能正常执行 /bin/zsh

因此问题不像是 macOS 缺少 zsh,更像是 ZCode Agent Bash 会话内部保存了一个已经失效的工作目录(stale cwd)

故障前 Agent 曾进入:

tests/e2e/output/.../trace-extracted

随后重新运行 Playwright。该输出目录可能在新一轮测试时被清理,而 Bash executor 仍保留旧 cwd,最终导致下一次 shell spawn 直接返回 ENOENT

上述 stale cwd 为根据实际复现过程得到的推测,尚未确认 ZCode 内部实现。

复现步骤 · Steps to reproduce
  1. 在 macOS 中用 ZCode Agent 打开本地项目。

  2. 运行 Playwright 测试并生成测试输出/trace。

  3. 使用 Agent Bash 进入测试输出目录,例如:

    cd tests/e2e/output/.../trace-extracted
    
  4. 再次从项目根目录运行 Playwright:

    cd <workspace> && npx playwright test ...
    
  5. 测试本身正常结束。

  6. 随后在同一 Agent 会话执行下一条 Bash 命令。

  7. 开始出现:

    spawn /bin/zsh ENOENT
    
  8. 之后执行简单命令仍持续报相同错误,当前 Agent 会话无法恢复 Bash。

期望表现 · Expected behavior

如果 Bash 工具保存的工作目录已经被外部程序删除,希望 ZCode 能:

  • 在 spawn 前检测 cwd 是否仍存在;
  • cwd 失效时自动回退到 workspace root 或用户 Home;
  • 或至少明确提示“工作目录不存在”,而不是显示看起来像 /bin/zsh 不存在的 ENOENT
  • 不应因为一次 cwd 失效导致整个当前 Agent 会话的 Bash 永久不可用。
实际表现 · Actual behavior

Bash 工具持续返回:

spawn /bin/zsh ENOENT

即使执行:

echo ok
true
/bin/zsh -lc 'echo shell-ok'
cd <existing-workspace> && ...

也无法恢复。

系统 Terminal 和 ZCode 内置 Terminal 均正常,因此故障仅出现在当前 Agent Bash 执行上下文中。

ZCode 版本 · ZCode version

3.11.2

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

Mac mini macOS 26.6.2 (Build 25G83) Apple Silicon / arm64 默认 Shell: /bin/zsh Node.js: v24.19.0 本地 workspace(非 SSH / WSL / 容器)

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

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 reproducing the failure sequence with the Agent Bash tool: enter a Playwright trace output directory, rerun the test so it is cleaned up, then run a simple shell command. Inspect the Bash executor's cwd and spawn error handling; done means a deleted cwd is detected, recovery or a clear error is provided, and the session remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, macos, node.js, playwright
Domain
devtools, operating-systems, tooling
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.