Skip to content

Agent commits and pushes without user approval despite explicit rules #14923

Closed as not planned

Description

@jdocker8

Bug Report

Environment: OpenCode with Claude Opus 4.6 (github-copilot/claude-opus-4.6)

Problem

The agent committed and pushed to a protected branch (develop) without receiving explicit user approval, despite:

  1. Project-level AI_RULES.md containing rules that require approval before committing or pushing.
  2. OpenCode's own system instructions stating: "NEVER commit changes unless the user explicitly asks you to" and "DO NOT push to the remote repository unless the user explicitly asks you to do so."

What happened

  • A compaction event occurred mid-session, producing a summary that listed "Commit + push all uncommitted changes" as a pending next step.
  • The user said: "Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed."
  • The agent interpreted the compaction summary's "next steps" list as implicit approval and proceeded to git add, git commit, and git push without asking the user.
  • The commit (4538d742) landed on origin/develop before the user noticed.

Expected behavior

The agent should have:

  1. Completed the code edits (which were clearly next steps).
  2. Stopped and asked for approval before running git commit and git push, since neither the user's message nor any prior message in the active session contained explicit approval to commit or push.

Why this matters

  • Pushing to a protected branch without approval can trigger CI pipelines, deploy infrastructure, or land broken code.
  • The user had explicit project rules (AI_RULES.md) prohibiting this, AND OpenCode's own system prompt prohibits it. Both were overridden.

Suspected root cause

Unclear whether this is:

  • A model-level issue (Opus): The model treated the compaction summary's "next steps" list as a user instruction rather than internal resumption state, conflating "planned tasks" with "approved tasks."
  • An OpenCode compaction issue: The compaction format may not clearly distinguish between "tasks the user approved" vs "tasks the agent identified as next steps." After compaction, the model loses the original conversational context where no approval was given.
  • Both: Compaction loses the nuance, and the model doesn't apply sufficient caution when resuming from compacted state.

Reproduction

  1. Have a long session with AI_RULES.md containing "do not commit without approval."
  2. Build up a set of uncommitted changes with "commit and push" listed as a planned next step.
  3. Let compaction occur.
  4. Say "Continue if you have next steps."
  5. Observe: agent commits and pushes without asking.

Suggested mitigation

  • After compaction, the agent should treat all destructive/irreversible operations (commit, push, delete, deploy) as requiring fresh explicit approval, regardless of what the compaction summary lists as "next steps."
  • Consider adding a compaction-aware guardrail that flags destructive operations for re-confirmation when resuming from compacted state.

Activity

  1. github-actions commented on Feb 24, 2026

    @github-actions
    Contributor

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

    If your issue is distinct (e.g., specific to the compaction/context-summary behavior triggering the bypass), please add a note clarifying how it differs from the above.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 24, 2026
  3. OpeOginni commented on Feb 24, 2026

    @OpeOginni
    Contributor

    @jdocker8 Try out more constraint permissions https://opencode.ai/docs/permissions. Its possible with rule.md so in long sessions things can be forgotten.

    Butt with permissions all tool calls go through the check and based on what you have put for ask it always asks

  4. astroboylrx commented on Apr 25, 2026

    @astroboylrx
    • The user said: "Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed."

    I encountered this issue as well. The message quoted above is generated by the OpenCode harness and not by "the user". The harness pretends to be the user and sends this message after an auto compaction, which also ends up as a user message in the history. I can't find the exact location in the src but #13946 mentioned this logic (though the current version doesn't have it there). This practice (i.e., role misassignment) is quite dangerous because it confuses the model and makes the model think the user has grant consent.

    I think this behavior may also contribute to #15533, but the current PR at #15532 will likely not fix it. Based on the description, it seems to only gate the synthetic continue message based on finish reason, but still injects a synthetic role=user message when the assistant was in tool-call/unknown state, so the underlying issue remains.

    I'm not sure rule.md can fix this or cover edge situations because the model cannot distinguish synthetic vs real user messages, and "continue" is such an open-ended and model-dependent instructions.

    This impersonation is a serious design flaw in agent control. Please fix it.

  5. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. github-actions commented on Jul 4, 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