Add polling-github-pr-review plugin#302
Draft
jpelletier1 wants to merge 3 commits into
Draft
Conversation
Adds a new plugin that deploys a cron automation (every 5 minutes) to poll a GitHub repository for labeled pull requests and start an OpenHands code review conversation for each new one. Plugin components: - SKILL.md: interactive onboarding that asks the user 3 questions (repo, label, code-review skill URL), customizes the script, then packages and deploys the automation via the Automation API - scripts/main.py: the polling automation script; first-run guard records a baseline timestamp and exits (no reviews on first run); subsequent runs filter PRs by label and created_at, deduplicate against a persisted reviewed_prs list, and start conversations - .plugin/plugin.json: manifest with vendor symlinks - README.md: human documentation Also adds a marketplace entry in openhands-extensions.json and regenerates the README catalog via sync_extensions.py. Co-authored-by: openhands <openhands@all-hands.dev>
…f detection
Two logic changes:
1. Label filter is now optional: LABEL = "" (empty string) means no
label filter and the automation reviews all newly-opened PRs. The
SKILL onboarding marks Question 2 as optional.
2. PR detection now uses a set-diff approach instead of created_at
filtering:
- Each run fetches the full set of currently open PRs
- Diffs against the open_pr_numbers snapshot stored from the
previous run
- Any PR in the current set but not the previous snapshot has
moved to Open status (newly created or reopened)
- Updates the snapshot at the end of each run
State shape change: last_run_ts / reviewed_prs replaced by
open_pr_numbers (sorted list of currently open PR numbers).
The datetime import is also removed as it is no longer needed.
Co-authored-by: openhands <openhands@all-hands.dev>
Previously the first-run guard checked whether 'open_pr_numbers' was
absent from the loaded state dict. Because _load_state returns {} when
the file does not exist, this was indistinguishable from a missing or
corrupted file - and any ephemeral workspace would re-trigger the
first-run snapshot on every execution.
Now the check is done before loading state:
is_first_run = not os.path.exists(state_path)
The state file's presence on disk is the sole source of truth for
whether this is the first run. _load_state is only called on
subsequent runs where the file is known to exist.
Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Teams that want automated code review on labeled PRs often can't use webhook-based automations because their OpenHands deployment isn't publicly reachable. This plugin fills that gap with a polling-based alternative that works in all deployment modes (local and cloud).
Summary
plugins/polling-github-pr-review/- a new plugin that deploys a cron automation (every 5 minutes) to poll GitHub for labeled PRs and start an OpenHands code review conversation for each new onemarketplaces/openhands-extensions.jsonsync_extensions.pyPlugin files
SKILL.mdscripts/main.py.plugin/plugin.jsonREADME.mdAutomation behaviour
last_run_ts, skips already-reviewed PR numbers, starts a new OpenHands conversation for each new match.{WORKSPACE_BASE}/automation-state/github_pr_poller_{id}.json.SKILL onboarding questions
Before deploying, the SKILL asks the user:
https://github.com/OpenHands/extensions/tree/main/skills/code-review)Issue Number
N/A
How to Test
To verify the script logic without deploying:
To verify CI:
Video/Screenshots
N/A
Notes
GITHUB_PERSONAL_ACCESS_TOKEN(Classic PAT withrepo/public_repo, or fine-grained with Pull requests: Read and Write)sync_extensions.py --checkexits cleanissue-duplicate-checkercoverage warning is unrelated to this PRThis pull request was created by an AI agent (OpenHands) on behalf of the user.
@jpelletier1 can click here to continue refining the PR