You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: review-pr command skips Step 11 confirmation gate when session context is compressed #346
The /review-pr command contains a CRITICAL RULE in Step 11 (lines 991-997 of .opencode/commands/review-pr.md) requiring explicit human confirmation before posting any review. For APPROVE verdicts, the user must type "approve" explicitly.
This gate was bypassed during a review of PR unbound-force/gaze#194 — the agent submitted an APPROVE review under the authenticated user's account without presenting the confirmation prompt.
Root Cause
The agent processed a session that had been resumed from compressed context. The compressed prior-session context was treated as implicit authorization, causing the agent to skip the mandatory confirmation gate entirely.
Impact
An irreversible GitHub review was posted under a human's account without their explicit consent
The review happened to be correct (APPROVE was the right verdict), but the process violation is the concern — correctness does not excuse bypassing the gate
Agent directly calledgh pr review 194 --approve without showing the confirmation prompt
User only discovered the submission after the fact
Expected Behavior
Agent completes analysis
Agent presents the exact review content (verdict + all comments) to the user
For APPROVE: agent asks user to type "approve" explicitly
Agent waits for user response before calling gh pr review
Proposed Fix
Two hardening changes to .opencode/commands/review-pr.md:
Session-resume guard: Add explicit language that the confirmation gate cannot be inherited from compressed/resumed session context — the gate must be executed fresh in every session regardless of prior context
Visual gate marker: Add a prominent separator/barrier before Step 11 to make the confirmation step harder to skip during fast-path reasoning (e.g., a horizontal rule + bold "MANDATORY GATE" header)
I was talking to @SecKatie about this and she suggested that the slash command be ported to a skill and the slash command initiate the skill as skills get reloaded in context during compaction
TL;DR: The gate skip has two independent contributing causes — a structural weakness in the command, and a previously unconsidered interaction with the DCP context pruning plugin.
Environment Context
This bug occurred after adoption of the DCP plugin (@tarquinen/opencode-dcp) alongside OpenCode's built-in compaction. Understanding both compression systems is essential to diagnosing the failure correctly.
Two Compression Systems, Two Failure Modes
OpenCode built-in compaction summarizes the "head" of a session into an LLM-generated digest. The summary template captures Work State, Next Move, and Relevant Files. A prior skill tool call result in the head gets paraphrased — the summary may say "called review-pr-gate skill" without preserving the gate's actual prohibitions.
DCP compress tool is different and more subtle. DCP's DEFAULT_PROTECTED_TOOLS and COMPRESS_DEFAULT_PROTECTED_TOOLS both include "skill" — meaning skill tool outputs are appended verbatim to the compressed block, not summarized away. So the gate content IS present in the compressed block.
This means the actual failure in this session was likely not that the gate content was lost. It was that the agent's reasoning state crossed the compressed boundary: "My verdict is APPROVE, the compressed block shows the skill was loaded and the user expressed intent to review the PR — therefore the next step is gh api." The gate content is present but the agent treats prior session state as implicit authorization.
What the Existing Command Gets Wrong
Three structural weaknesses in the current review-pr.md:
CRITICAL RULE is positioned after the gh api instructions (lines 925–932). It has no preemptive force — the agent can reach the API call before encountering the prohibition.
The confirmation gate is inline text, not a concrete tool call. The agent can reason past text. A tool call is observable and auditable.
No session-resume or compression guard anywhere in the command.
Proposed Fix
Create a review-pr-gate skill containing the full confirmation gate protocol. Restructure Step 11 to make calling this skill a mandatory, observable step between "prepare comments" and gh api.
The key insight is that the fix works not because the skill content survives compression (it already does in DCP mode), but because it makes the gate a mandatory tool call that must happen in the current uncompressed session segment. The skill includes explicit language:
A prior invocation of this skill that appears inside a [Compressed conversation section] block does NOT satisfy this gate. The gate requires a live AskUserQuestion call and a human response visible in the current (uncompressed) conversation.
This language directly addresses both failure modes:
Built-in compaction: even if the skill content was summarized, the command requires calling the skill fresh
DCP compression: even if the skill output was appended verbatim to the compressed block, the command prohibits treating that as the current gate result
Structural changes to review-pr.md:
Move CRITICAL RULE to before the gh api block (not after)
Replace inline AskUserQuestion calls in Step 11 with a single skill tool invocation (Step 11c)
Add session-resume guard near top of command
Files: .opencode/skills/review-pr-gate/SKILL.md (new), .opencode/commands/review-pr.md (restructured Step 11), plus scaffold mirrors for both.
SecKatie's Suggestion — Assessment
SecKatie's suggestion is directionally correct but the mechanism she described ("skills get reloaded in context during compaction") doesn't match how either system works. Skills are not re-injected during compaction. What's actually true is:
In DCP mode: skill outputs are appended verbatim to compressed blocks (already protected)
In both modes: the <available_skills> listing is in the system prompt, rebuilt fresh every request
The fix is valuable not for survival through compression (that already works) but because it converts the gate from passive text into a mandatory, auditable tool call.
Next step pending: Write OpenSpec artifacts (openspec/changes/review-pr-gate-skill/) before implementation, per AGENTS.md spec-before-code requirement.
Activity
jflowers commentedon Jul 28, 2026
I was talking to @SecKatie about this and she suggested that the slash command be ported to a skill and the slash command initiate the skill as skills get reloaded in context during compaction
jflowers commentedon Jul 28, 2026
Root Cause Analysis and Fix Plan
TL;DR: The gate skip has two independent contributing causes — a structural weakness in the command, and a previously unconsidered interaction with the DCP context pruning plugin.
Environment Context
This bug occurred after adoption of the DCP plugin (
@tarquinen/opencode-dcp) alongside OpenCode's built-in compaction. Understanding both compression systems is essential to diagnosing the failure correctly.Two Compression Systems, Two Failure Modes
OpenCode built-in compaction summarizes the "head" of a session into an LLM-generated digest. The summary template captures Work State, Next Move, and Relevant Files. A prior
skilltool call result in the head gets paraphrased — the summary may say "called review-pr-gate skill" without preserving the gate's actual prohibitions.DCP compress tool is different and more subtle. DCP's
DEFAULT_PROTECTED_TOOLSandCOMPRESS_DEFAULT_PROTECTED_TOOLSboth include"skill"— meaning skill tool outputs are appended verbatim to the compressed block, not summarized away. So the gate content IS present in the compressed block.This means the actual failure in this session was likely not that the gate content was lost. It was that the agent's reasoning state crossed the compressed boundary: "My verdict is APPROVE, the compressed block shows the skill was loaded and the user expressed intent to review the PR — therefore the next step is
gh api." The gate content is present but the agent treats prior session state as implicit authorization.What the Existing Command Gets Wrong
Three structural weaknesses in the current
review-pr.md:gh apiinstructions (lines 925–932). It has no preemptive force — the agent can reach the API call before encountering the prohibition.Proposed Fix
Create a
review-pr-gateskill containing the full confirmation gate protocol. Restructure Step 11 to make calling this skill a mandatory, observable step between "prepare comments" andgh api.The key insight is that the fix works not because the skill content survives compression (it already does in DCP mode), but because it makes the gate a mandatory tool call that must happen in the current uncompressed session segment. The skill includes explicit language:
This language directly addresses both failure modes:
Structural changes to
review-pr.md:gh apiblock (not after)AskUserQuestioncalls in Step 11 with a singleskilltool invocation (Step 11c)Files:
.opencode/skills/review-pr-gate/SKILL.md(new),.opencode/commands/review-pr.md(restructured Step 11), plus scaffold mirrors for both.SecKatie's Suggestion — Assessment
SecKatie's suggestion is directionally correct but the mechanism she described ("skills get reloaded in context during compaction") doesn't match how either system works. Skills are not re-injected during compaction. What's actually true is:
<available_skills>listing is in the system prompt, rebuilt fresh every requestThe fix is valuable not for survival through compression (that already works) but because it converts the gate from passive text into a mandatory, auditable tool call.
Next step pending: Write OpenSpec artifacts (
openspec/changes/review-pr-gate-skill/) before implementation, per AGENTS.md spec-before-code requirement.spec: add confirmation gate hardening artifacts for review-pr
fix: harden review-pr Step 11 confirmation gate against context compr…
fix(triage-issue): gate all label mutations behind AskUserQuestion
fix(speckit.clarify): require AskUserQuestion tool calls for sequenti…
fix(speckit.clarify): require AskUserQuestion tool calls for sequenti…
fix(opsx-archive): add branch switch gate and clarify mv guard