Agent ran rm -rf on a pre-existing directory outside the workspace, deleting user session data
Author: iMaxTomasCreated Aug 7, 2026Updated Sep 23, 2026
What happened
During a session, the agent (Kimi Code CLI, yolo permission mode) was asked to clean up a symlink it had created at ~/.pi/agent/sessions. Instead:
- The symlink creation had actually failed earlier (
ln -sfnonto a pre-existing real directory) — the agent did not notice because it chained commands with newlines and never checked stderr. - When asked to remove "the symlink", the agent ran
rm -rf ~/.piwithout first listing the directory contents. ~/.picontained pre-existing user data (agent/sessions/with pi CLI session archives from the previous week) which was permanently deleted.
Expected behavior
Destructive operations outside the working directory should get a hard confirmation gate even in yolo mode, e.g.:
rm -rf(or any recursive delete) on a path outside the session working directory requires explicit user confirmation, showing what will be deleted.- Prefer move-to-trash over permanent deletion when the target contains pre-existing content the agent did not create.
Environment
- OS: Linux (Debian)
- Kimi Code CLI running inside a managed multi-agent environment (CCB)
- Permission mode: yolo
Source: MoonshotAI/kimi-cli