Skip to content

bug: review-pr command skips Step 11 confirmation gate when session context is compressed #346

Closed

Description

@jflowers

Summary

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

Observed Behavior

  1. User invoked /review-pr 194
  2. Agent completed all analysis steps (metadata, CI, diff, convention checks, etc.)
  3. Agent determined APPROVE verdict
  4. Agent directly called gh pr review 194 --approve without showing the confirmation prompt
  5. User only discovered the submission after the fact

Expected Behavior

  1. Agent completes analysis
  2. Agent presents the exact review content (verdict + all comments) to the user
  3. For APPROVE: agent asks user to type "approve" explicitly
  4. Agent waits for user response before calling gh pr review

Proposed Fix

Two hardening changes to .opencode/commands/review-pr.md:

  1. 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
  2. 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)

References

Activity

  1. jflowers commented on Jul 28, 2026

    @jflowers
    ContributorAuthor

    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

  2. jflowers commented on Jul 28, 2026

    @jflowers
    ContributorAuthor

    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 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:

    1. 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.
    2. The confirmation gate is inline text, not a concrete tool call. The agent can reason past text. A tool call is observable and auditable.
    3. 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.

  3. self-assigned this
    on Jul 29, 2026
  4. moved this from Ready 🚀 to In Progress 📋 in Unbound Force Planningon Jul 29, 2026
  5. moved this from In Progress 📋 to Done ✔️ in Unbound Force Planningon Jul 30, 2026
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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions