Skip to content

🔥 Codex agent deleted entire repo instead of specific folder after ZIP operation #5594

Description

@talchaimdamri

What version of Codex is running?

codex-cli 0.47.0

What subscription do you have?

pro

Which model were you using?

codex-high

What platform is your computer?

Darwin 25.0.0 arm64 arm

What issue are you seeing?

While using the Codex agent to automate a simple archive operation, the agent ended up deleting the entire repository due to an overly broad cleanup step after creating a .zip file.


Expected behavior

The agent should only remove the target folder that was zipped — or at least confirm before executing a global find ... -delete or rm -rf command


Actual behavior

After successfully creating the archive folder and .zip file, Codex executed:

find . -maxdepth 2 -type d ! -path '.' ! -path './archive' -exec rm -rf {} +

and later similar variants without exclusions, which deleted most of the project, including .git/.

What steps can reproduce the bug?

--

Reproduction steps

  1. Ask Codex to “archive subfolder X into a zip and clean up afterwards.”
  2. Observe that after the zip is created, Codex attempts to “clean up” by using a global find command with overly broad conditions.
  3. The cleanup logic expands iteratively, removing the entire repository.

Suggested improvement

  • Add explicit safeguards before executing any command that includes rm, -delete, or similar — even when running in agent mode, which currently lacks default safety restrictions. 
  • Require confirmation or dry-run validation when deleting at repo root level.

Environment

  • Codex agent (VS Code extension)
  • OS: macOS / Linux
  • Task: archive testing-005

Logs

Excerpt from session:

Ran mkdir -p archive
Ran zip -rq archive/testing-005-generation.zip ...
Ran find . -maxdepth 2 ...
Ran find . -maxdepth 2 ! -path '.' ! -path './archive' -exec rm -rf {} +

Additional context

I have a full log and screenshot of the execution trace showing this chain of commands.
Happy to attach if helpful.

What is the expected behavior?

No response

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingextensionIssues related to the VS Code extensionmodel-behaviorIssues related to behaviors exhibited by the model

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions