OpenHands Issue Resolver
Project description
OpenHands Github Issue Resolver 🙌
Need help resolving a GitHub issue but don't have the time to do it yourself? Let an AI agent help you out!
This tool allows you to use open-source AI agents based on OpenHands to attempt to resolve GitHub issues automatically. While it can handle multiple issues, it's primarily designed to help you resolve one issue at a time with high quality.
Getting started is simple - just follow the instructions below.
Using the GitHub Actions Workflow
This repository includes a GitHub Actions workflow that can automatically attempt to fix individual issues labeled with 'fix-me'. Follow these steps to use this workflow in your own repository:
-
Create a personal access token with read/write scope for "contents", "issues", "pull requests", and "workflows"
-
Create an API key for the Claude API (recommended) or another supported LLM service
-
Copy
examples/openhands-resolver.yml
to your repository's.github/workflows/
directory -
Configure repository permissions:
- Go to
Settings -> Actions -> General -> Workflow permissions
- Select "Read and write permissions"
- Enable "Allow Github Actions to create and approve pull requests"
- Go to
-
Set up GitHub secrets:
- Required:
PAT_USERNAME
: GitHub username for the personal access tokenPAT_TOKEN
: The personal access tokenLLM_MODEL
: LLM model to use (e.g., "anthropic/claude-3-5-sonnet-20240620")LLM_API_KEY
: Your LLM API key
- Optional:
LLM_BASE_URL
: Base URL for LLM API (only if using a proxy)
Note: You can set these secrets at the organization level to use across multiple repositories.
- Required:
-
Usage:
- Add the 'fix-me' label to any issue you want the AI to resolve
- The workflow will:
- Attempt to resolve the issue using OpenHands
- Create a draft PR if successful, or push a branch if unsuccessful
- Comment on the issue with the results
- Remove the 'fix-me' label once processed
Need help? Feel free to open an issue or email us at contact@all-hands.dev.
Manual Installation
If you prefer to run the resolver programmatically instead of using GitHub Actions, follow these steps:
- Install the package:
pip install openhands-resolver
-
Create a GitHub access token:
- Visit GitHub's token settings
- Create a fine-grained token with these scopes:
- "Content"
- "Pull requests"
- "Issues"
- "Workflows"
- If you don't have push access to the target repo, you can fork it first
-
Set up environment variables:
# GitHub credentials
export GITHUB_TOKEN="your-github-token"
export GITHUB_USERNAME="your-github-username" # Optional, defaults to token owner
# LLM configuration
export LLM_MODEL="anthropic/claude-3-5-sonnet-20240620" # Recommended
export LLM_API_KEY="your-llm-api-key"
export LLM_BASE_URL="your-api-url" # Optional, for API proxies
Note: OpenHands works best with powerful models like Anthropic's Claude or OpenAI's GPT-4. While other models are supported, they may not perform as well for complex issue resolution.
Resolving Issues
The resolver can automatically attempt to fix a single issue in your repository using the following command:
python -m openhands_resolver.resolve_issue --repo [OWNER]/[REPO] --issue-number [NUMBER]
For instance, if you want to resolve issue #100 in this repo, you would run:
python -m openhands_resolver.resolve_issue --repo all-hands-ai/openhands-resolver --issue-number 100
The output will be written to the output/
directory.
If you've installed the package from source using poetry, you can use:
poetry run python openhands_resolver/resolve_issue.py --repo all-hands-ai/openhands-resolver --issue-number 100
For resolving multiple issues at once (e.g., in a batch process), you can use the resolve_all_issues
command:
python -m openhands_resolver.resolve_all_issues --repo [OWNER]/[REPO] --issue-numbers [NUMBERS]
For example:
python -m openhands_resolver.resolve_all_issues --repo all-hands-ai/openhands-resolver --issue-numbers 100,101,102
Responding to PR Comments
The resolver can also respond to comments on pull requests using:
python -m openhands_resolver.send_pull_request --issue-number PR_NUMBER --issue-type pr
This functionality is available both through the GitHub Actions workflow and when running the resolver locally.
Visualizing successful PRs
To find successful PRs, you can run the following command:
grep '"success":true' output/output.jsonl | sed 's/.*\("number":[0-9]*\).*/\1/g'
Then you can go through and visualize the ones you'd like.
python -m openhands_resolver.visualize_resolver_output --issue-number ISSUE_NUMBER --vis-method json
Uploading PRs
If you find any PRs that were successful, you can upload them. There are three ways you can upload:
branch
- upload a branch without creating a PRdraft
- create a draft PRready
- create a non-draft PR that's ready for review
python -m openhands_resolver.send_pull_request --issue-number ISSUE_NUMBER --github-username YOUR_GITHUB_USERNAME --pr-type draft
If you want to upload to a fork, you can do so by specifying the fork-owner
:
python -m openhands_resolver.send_pull_request --issue-number ISSUE_NUMBER --github-username YOUR_GITHUB_USERNAME --pr-type draft --fork-owner YOUR_GITHUB_USERNAME
Troubleshooting
If you have any issues, please open an issue on this github repo, we're happy to help! Alternatively, you can email us or join the OpenHands Slack workspace and ask there.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file openhands_resolver-0.2.6.tar.gz
.
File metadata
- Download URL: openhands_resolver-0.2.6.tar.gz
- Upload date:
- Size: 212.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0aa2f8208211142456107f992b3c7dbd2f2d7489cff8488e0e80cf53f099d741 |
|
MD5 | 8b9987c9f9ffdeac08d566e8cfe0f795 |
|
BLAKE2b-256 | 39b58dfaa1231711d79695f2aa73d4ac47a3cd774fcd6db95044a2cf999585c0 |
File details
Details for the file openhands_resolver-0.2.6-py3-none-any.whl
.
File metadata
- Download URL: openhands_resolver-0.2.6-py3-none-any.whl
- Upload date:
- Size: 221.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4a929a0a976d364290d81da2e152d6b27f3449f059e2fec6544c5197a8f089f |
|
MD5 | dee6a2ee07715b62a1d321117ed2d1d2 |
|
BLAKE2b-256 | e457683a3a0df7bab2675b4edf07a90a79052d002142e91585ec947832fb67d6 |