Automated pull request review using OpenHands agents. This plugin provides GitHub workflows that automatically review PRs with detailed, inline code review comments.
Copy both workflow files to your repository:
mkdir -p .github/workflows
curl -o .github/workflows/pr-review-by-openhands.yml \
https://raw.githubusercontent.com/OpenHands/extensions/main/.github/workflows/pr-review-by-openhands.yml
curl -o .github/workflows/pr-review-evaluation.yml \
https://raw.githubusercontent.com/OpenHands/extensions/main/.github/workflows/pr-review-evaluation.ymlThen configure the required secrets (see Installation below).
- Automated PR Reviews: Triggered when PRs are opened, marked ready, or when a reviewer is requested
- Inline Code Comments: Posts review comments directly on specific lines of code
- Unified Review Style: Rigorous code review combining pragmatic engineering analysis with data structure and simplicity focus
- A/B Testing: Support for testing multiple LLM models
- Review Context Awareness: Considers previous reviews and unresolved threads
- Evidence Enforcement: Optional check that PR descriptions include concrete end-to-end proof the code works, not just test output
- Sub-Agent Delegation (Experimental): Split large PR reviews across multiple sub-agents, one per file, then consolidate findings (see Known Limitations)
- Observability: Optional Laminar integration for tracing and evaluation
plugins/pr-review/
├── README.md # This file
├── action.yml # Composite GitHub Action
├── skills/ # Symbolic links to review skills
│ ├── code-review -> ../../../skills/code-review
│ └── github-pr-review -> ../../../skills/github-pr-review
├── workflows/ # Example GitHub workflow files
│ ├── pr-review-by-openhands.yml
│ └── pr-review-evaluation.yml
└── scripts/ # Python scripts for review execution
├── agent_script.py # Main PR review agent script
├── prompt.py # Prompt template for reviews
└── evaluate_review.py # Evaluation script for merged/closed PRs
Copy the workflow files to your repository's .github/workflows/ directory:
mkdir -p .github/workflows
curl -o .github/workflows/pr-review-by-openhands.yml \
https://raw.githubusercontent.com/OpenHands/extensions/main/.github/workflows/pr-review-by-openhands.yml
curl -o .github/workflows/pr-review-evaluation.yml \
https://raw.githubusercontent.com/OpenHands/extensions/main/.github/workflows/pr-review-evaluation.ymlAdd the following secrets in your repository settings (Settings → Secrets and variables → Actions):
| Secret | Required | Description |
|---|---|---|
LLM_API_KEY |
Yes | API key for your LLM provider |
GITHUB_TOKEN |
Auto | Provided automatically by GitHub Actions |
LMNR_SKILLS_API_KEY |
No | Laminar API key (org-level secret; mapped to LMNR_PROJECT_API_KEY env var in workflows) |
Note: For repositories that need to post review comments from a bot account, use ALLHANDS_BOT_GITHUB_PAT instead of GITHUB_TOKEN.
Edit the workflow file to customize:
- name: Run PR Review
uses: OpenHands/extensions/plugins/pr-review@main
with:
# LLM model(s) - comma-separated for A/B testing
llm-model: anthropic/claude-sonnet-4-5-20250929
# Optional: Custom LLM endpoint
# llm-base-url: https://your-llm-proxy.example.com
# [DEPRECATED] review-style is no longer used; standard and roasted are merged
# review-style: roasted
# Optional: require an Evidence section proving the code works end-to-end
# require-evidence: 'true'
# Pin to a specific version (tag, branch, or commit SHA)
extensions-version: main
# Secrets
llm-api-key: ${{ secrets.LLM_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
# Optional: Enable Laminar observability
# lmnr-api-key: ${{ secrets.LMNR_PROJECT_API_KEY }}Create a review-this label for manual review triggers:
- Go to Issues → Labels in your repository
- Click New label
- Name:
review-this - Description:
Trigger OpenHands PR review - Click Create label
PR reviews are automatically triggered when:
- A new non-draft PR is opened (by non-first-time contributors)
- A draft PR is marked as ready for review
- The
review-thislabel is added openhands-agentorall-hands-botis requested as a reviewer
Option 1: Request as Reviewer (Recommended)
- Open the PR
- Click Reviewers in the sidebar
- Select
openhands-agentas a reviewer
Option 2: Add Label
- Open the PR
- Add the
review-thislabel
| Input | Required | Default | Description |
|---|---|---|---|
llm-model |
No | anthropic/claude-sonnet-4-5-20250929 |
LLM model(s), comma-separated for A/B testing |
llm-base-url |
No | '' |
Custom LLM endpoint URL |
review-style |
No | roasted |
[DEPRECATED] Previously chose between standard and roasted review styles. Now ignored — the styles have been merged into a single unified skill. |
require-evidence |
No | 'false' |
Require the reviewer to enforce an Evidence section in the PR description with end-to-end proof: screenshots/videos for frontend work, commands and runtime output for backend or scripts, and an agent conversation link when applicable. Test output alone does not qualify. |
use-sub-agents |
No | 'false' |
(Experimental) Enable sub-agent delegation for file-level reviews. The main agent acts as a coordinator that delegates per-file review work to file_reviewer sub-agents via the SDK TaskToolSet, then consolidates findings into a single PR review. Useful for large PRs with many changed files. |
extensions-repo |
No | OpenHands/extensions |
Extensions repository |
extensions-version |
No | main |
Git ref (tag, branch, or SHA) |
llm-api-key |
Yes | - | LLM API key |
github-token |
Yes | - | GitHub token for API access |
lmnr-api-key |
No | '' |
Laminar API key for observability |
The use-sub-agents feature is experimental and has the following known constraints:
- LLM-driven JSON parsing: The coordinator agent relies on the LLM to parse and merge JSON responses from sub-agents. There is no code-level validation of sub-agent output, so malformed responses may cause incomplete reviews.
- Potential information loss during consolidation: When merging findings from multiple sub-agents, the coordinator may lose or deduplicate findings imperfectly, especially for cross-file issues.
- No integration tests yet: Current test coverage verifies prompt formatting only. End-to-end validation of the delegation flow requires manual workflow testing.
- Sub-agents have no tools: File reviewer sub-agents analyse the diff in their context window only — they cannot run commands or query the GitHub API.
These limitations are acceptable for an opt-in experimental feature and will be addressed as the feature matures.
Test different LLM models by providing a comma-separated list:
llm-model: 'anthropic/claude-sonnet-4-5-20250929,openai/gpt-4o,anthropic/claude-3-5-haiku-20241022'One model is randomly selected for each review. When Laminar observability is enabled, the selected model is logged for comparison.
- Create a project at Laminar
- Copy your project API key
- Add
LMNR_PROJECT_API_KEYto your repository secrets - Uncomment the
lmnr-api-keyline in your workflow
- Review Trace: Full agent execution including diff analysis, review generation, and comment posting
- Metadata: PR number, repository, review style, model used
- Evaluation Trace: (Optional) Created when PR is closed/merged to measure review effectiveness
The evaluation workflow (pr-review-evaluation.yml) runs when PRs are closed and:
- Downloads the review trace artifact
- Fetches final PR state and comments
- Creates an evaluation span in Laminar
- Scores the review based on engagement metrics
In your Laminar dashboard, you can:
- Filter traces by
pr-revieworpr-review-evaluationtags - Compare review effectiveness across models (A/B testing)
- Analyze engagement metrics (human responses to agent comments)
- Set up signals for automated quality scoring
Instead of forking the scripts, add custom guidelines to your repository:
Create .agents/skills/custom-codereview-guide.md:
---
name: custom-codereview-guide
description: Custom code review guidelines for my project
triggers:
- /codereview
---
# My Project Code Review Guidelines
You are a code reviewer for this project. Follow these guidelines:
## Review Focus
- Security vulnerabilities and data handling
- API contract compatibility
- Test coverage for new functionality
## Communication Style
- Be direct and constructive
- Use GitHub suggestion syntax for code fixesUse a unique skill name (for example custom-codereview-guide) to supplement the default public code-review skill,
rather than overriding it. Keep /codereview as the trigger if you want this guidance applied in PR review runs.
Add project-specific context to AGENTS.md at your repository root:
# Project Context
This is a Python web application using FastAPI.
## Code Standards
- All public functions must have docstrings
- Use type hints for function signatures
- Follow PEP 8 style guidelinesIf you were previously using workflows that referenced OpenHands/software-agent-sdk, update them to use this extensions repository:
Before:
uses: OpenHands/software-agent-sdk/.github/actions/pr-review@mainAfter:
uses: OpenHands/extensions/plugins/pr-review@mainAlso update any sdk-repo and sdk-version inputs to extensions-repo and extensions-version.
- Check that the workflow file is in
.github/workflows/ - Verify the PR author association (first-time contributors need manual trigger)
- Ensure secrets are configured correctly
- Check the
GITHUB_TOKENhas write permissions for pull requests - Review the workflow logs for API errors
- Verify the LLM API key is valid
If you see rate limit errors:
- Reviews are automatically paginated to avoid limits
- Consider using a dedicated bot token for high-volume repositories
- Uses
pull_request_targetwhen you need secrets for fork PR reviews; apply strict maintainer-controlled triggers and checkout safeguards - Keeps GitHub Actions caching disabled in privileged review workflows to avoid cache-poisoning pivots from prompt injection
- For lower-trust or comment-only smoke-test setups, prefer
pull_requestto reduce privilege by default - Only triggers for trusted contributors or when maintainers add labels/reviewers
- PR code is checked out explicitly; secrets are not exposed to PR code
- Credentials are not persisted during checkout
See the main extensions repository for contribution guidelines.
This plugin is part of the OpenHands extensions repository. See LICENSE for details.