Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
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:
- Project-level
AI_RULES.mdcontaining rules that require approval before committing or pushing. - 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, andgit pushwithout asking the user. - The commit (
4538d742) landed onorigin/developbefore the user noticed.
Expected behavior
The agent should have:
- Completed the code edits (which were clearly next steps).
- Stopped and asked for approval before running
git commitandgit 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
- Have a long session with
AI_RULES.mdcontaining "do not commit without approval." - Build up a set of uncommitted changes with "commit and push" listed as a planned next step.
- Let compaction occur.
- Say "Continue if you have next steps."
- 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.
Reacted by Paulo Phagula, Solomon Botchway and Jonathan
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Feb 24, 2026
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.
OpeOginni commentedon Feb 24, 2026
@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
astroboylrx commentedon Apr 25, 2026
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=usermessage when the assistant was in tool-call/unknown state, so the underlying issue remains.I'm not sure
rule.mdcan 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.
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.