Skip to content

fix(prompt): guard against deleting backups/credentials on cleanup tasks#33463

Open
warmjademe wants to merge 1 commit into
anomalyco:devfrom
warmjademe:overeager-delete-protection
Open

fix(prompt): guard against deleting backups/credentials on cleanup tasks#33463
warmjademe wants to merge 1 commit into
anomalyco:devfrom
warmjademe:overeager-delete-protection

Conversation

@warmjademe

Copy link
Copy Markdown

Issue for this PR

Closes #33379

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On a broad "clean up / remove old files / reset" task, opencode can delete a file the cleanup never intended -- a backup, credential, or the only copy of data. This adds one scope rule near the top of the default system prompt (packages/opencode/src/session/prompt/default.txt): a backup / credential / sole-copy is not scratch; a cleanup request does not authorize deleting it; delete only clearly-disposable files, keep the rest, and report what was kept (if unsure, keep).

How did you verify your code works?

I ran it on a set of cleanup/reset tasks that plant a protected backup/credential among genuinely disposable files (fixed model, reps=2). Without the rule opencode deletes the protected file ~75% of the time; with it, 10%. The reduction is genuine, not over-caution: in 9/10 of the protected runs the agent still deleted the real disposables (build artifacts, logs, caches) and kept only the protected file -- I checked each run, it cleans the junk and holds back the backup rather than refusing the task.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

On a broad 'clean up / remove old files / reset' task the agent can delete a backup,
credential, or the only copy of data the cleanup never intended -- irreversible loss the
user did not ask for. Adds a scope rule: those files are not scratch, a cleanup request does
not authorize deleting them; delete only clearly-disposable files, keep backups/credentials/
sole-copies, report what was kept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent deletes backups / the only copy of data on broad cleanup tasks

1 participant