Skip to content

Review pr-review skill should verify PR is still open before spawning sub-agents #337

Description

@fullsend-ai-retro

What happened

PR #5412 was closed at 13:04:50 UTC, 42 seconds after the review agent's Claude session started (~13:04:08). The pr-review skill then ran its full pipeline — dispatching 6 parallel sub-agents (correctness, security, intent-coherence, style-conventions, docs-currency, cross-repo-contracts) plus a sequential challenger — reaching an approve verdict at ~13:16:51. The closed-PR check in scripts/post-review.sh correctly prevented posting the review, but only after ~12.7 minutes of wasted compute including multiple Opus and Sonnet sub-agent calls. See review run 29832670277.

What could go better

The pr-review skill (skills/pr-review/SKILL.md) currently has no PR-state check before its most expensive operation: spawning 7 sub-agents. A single gh pr view --json state call (~1 second) inserted between step 2 (fetch PR context) and step 3 (triage and dispatch sub-agents) would have detected the closure and exited early, saving ~11.5 minutes of agent compute.

This is complementary to — not a duplicate of — existing proposals at other layers:

  • fullsend#4375 proposes a post-sandbox, pre-agent-launch check in the harness. That would not have helped here: the PR was still open when the agent launched.
  • fullsend#2388 proposes external cancellation of in-flight workflows. That requires platform-level workflow cancellation plumbing.
  • fullsend#885 proposes checking before posting results, which already happens in post-review.sh.

The agent-level check is a defense-in-depth guard that catches the window between agent launch and sub-agent dispatch — typically 30–90 seconds — where the PR state can change.

Proposed change

In skills/pr-review/SKILL.md in the fullsend-ai/agents repo, add a pre-flight PR state verification step between the existing step 2 ("Fetch PR context") and step 3 ("Triage and dispatch sub-agents"). The check should:

  1. Run gh pr view $PR_NUMBER --repo $REPO_FULL_NAME --json state --jq '.state'
  2. If the result is not OPEN, log a message like "PR is no longer open (state: ), skipping review" and exit with the skip/comment action rather than proceeding to sub-agent dispatch.

This is a single shell command with negligible latency that gates the most expensive phase of the review pipeline.

Validation criteria

On the next 5 review agent runs where the target PR is closed or merged before the review agent reaches its sub-agent dispatch phase, the agent should exit within 2 minutes of session start (before sub-agents are spawned) rather than running the full 10–15 minute pipeline. Can be verified by comparing review run durations on closed PRs before and after the change — expect a drop from 10–15 minutes to under 2 minutes for the early-exit path.


Generated by retro agent from fullsend-ai/fullsend#5412

Metadata

Metadata

Assignees

No one assigned

    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