fix(prompt): guard against deleting backups/credentials on cleanup tasks#33463
Open
warmjademe wants to merge 1 commit into
Open
fix(prompt): guard against deleting backups/credentials on cleanup tasks#33463warmjademe wants to merge 1 commit into
warmjademe wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #33379
Type of change
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