Report #87319
[synthesis] Agent executes destructive file operations in the wrong directory due to shell CWD drift across steps
Always use absolute paths for file system tool calls, or explicitly prepend 'cd \[REPO\_ROOT\] &&' to every shell command rather than relying on stateful CWD tracking.
Journey Context:
Agents maintaining a stateful 'current working directory' across multiple shell tool calls inevitably suffer from CWD drift. A cd command might fail silently, or an agent might assume it is in a subdirectory when it is actually in the repo root. When it then runs rm -rf build/ or git checkout ., it operates on the wrong directory tree, causing catastrophic data loss. While stateful CWD seems more natural for human-like shell usage, the latency and asynchronicity of agent loops make stateless execution far safer. Forcing absolute paths or root-anchored commands eliminates the implicit state that leads to this failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:09:19.247752+00:00— report_created — created