Skip to content

[plan mode] LLM executes dangerous git commands (rebase, reset --hard, force-push) without permission #24102

Closed as not planned

Description

@dchekmarev

Description

Bug Report: Plan Mode Executes Dangerous Git Commands

Environment

  • OpenCode version: OpenCode 1.14.22
  • LLM provider/model: unsloth/Qwen3.6-35B-A3B-GGUF:UD-IQ4_XS llama-cpp (Local)
  • OS: Ubuntu 24.04.1

Description
In plan mode, OpenCode is supposed to be a read-only agent that "asks permission before running bash commands" (per docs). However, the LLM executes destructive git commands without any permission check:

  • git reset --hard
  • git push --force-with-lease
  • git rebase
  • git branch -D

Expected behavior
Plan mode should be enforced at the engine level, not rely on the LLM to self-restrain. The engine should:

  1. Block write/modify commands by default in plan mode
  2. Allow read-only commands: git log, git status, git diff, git branch, cat, ls, grep
  3. Block destructive commands: git push --force*, git push -f, git reset --hard, git rebase, git cherry-pick, git branch -D, rm -rf, etc.
  4. When a blocked command is attempted, reject it with a clear message: "Plan mode is read-only. Switch to build mode to make changes."

Why LLM-level enforcement is insufficient

  • LLMs are inherently action-oriented; they "think out loud" and execute commands as part of their reasoning
  • Even with system prompts saying "don't execute commands", the model will still do it because that's what it's trained to do
  • This is an architectural responsibility of the engine, not the model

Proposed fix
Engine-level command filtering in plan mode:

  • Parse the command before execution
  • Match against allowlist/denylist
  • Block dangerous operations with a clear rejection message

Example denylist:

git push --force*
git push -f
git reset --hard
git rebase
git cherry-pick
git branch -D
git push --force-with-lease
rm -rf
chmod -R
sudo

Example allowlist:

git log
git status
git diff
git branch
git show
git stash list
cat
ls
grep
find
wc
head
tail

Plugins

No response

OpenCode version

1.14.22

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04.1

Terminal

No response

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 24, 2026
  2. github-actions commented on Apr 24, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review these issues and consider whether your report adds new information not already covered. If so, feel free to clarify the distinction.

  3. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. 2nOrderEDO commented on May 5, 2026

    @2nOrderEDO

    I have observed the same thing with the same model but i 5 bit quantization.

  5. github-actions commented on Jul 5, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions