Skip to content

πŸ™Œ OpenHands: AI-Driven Development

[Feat]: Gitlab resolver (#8770)

Rohit Malhotra972837ff73f4
diff --git a/openhands/integrations/templates/resolver/github/issue_comment_conversation_instructions.j2 b/openhands/integrations/templates/resolver/github/issue_comment_conversation_instructions.j2
index 3862a97858..1eeb5cd8aa 100644
--- a/openhands/integrations/templates/resolver/github/issue_comment_conversation_instructions.j2
+++ b/openhands/integrations/templates/resolver/github/issue_comment_conversation_instructions.j2
@@ -12,7 +12,7 @@ A comment on the issue has been addressed to you.
When you're done, make sure to
1. Re-read the issue title, body, and comments and make sure that you have successfully implemented all requirements.
-2. Use the `GITHUB_TOKEN` environment variable and GitHub API to open a new PR
+2. Use the `create_pr` tool to open a new PR
3. Name the branch using `openhands/` as a prefix (e.g `openhands/update-readme`)
4. The PR description should mention that it "fixes" or "closes" the issue number
5. Make sure to leave the following sentence at the end of the PR description: `@{{ username }} can click here to [continue refining the PR]({{ conversation_url }})`
diff --git a/openhands/integrations/templates/resolver/github/issue_labeled_conversation_instructions.j2 b/openhands/integrations/templates/resolver/github/issue_labeled_conversation_instructions.j2
index aac2b542dc..ddd8424df5 100644
--- a/openhands/integrations/templates/resolver/github/issue_labeled_conversation_instructions.j2
+++ b/openhands/integrations/templates/resolver/github/issue_labeled_conversation_instructions.j2
@@ -7,6 +7,6 @@ Your tasking is to fix an issue in your repository. Do the following
When you're done, make sure to
-1. Use the `GITHUB_TOKEN` environment variable and GitHub API to open a new PR
+1. Use the `create_pr` tool to open a new PR
2. The PR description should mention that it "fixes" or "closes" the issue number
3. Make sure to leave the following sentence at the end of the PR description: `@{{ username }} can click here to [continue refining the PR]({{ conversation_url }})`
diff --git a/openhands/integrations/templates/resolver/gitlab/issue_comment_conversation_instructions.j2 b/openhands/integrations/templates/resolver/gitlab/issue_comment_conversation_instructions.j2
new file mode 100644
index 0000000000..beb8be821e
--- /dev/null
+++ b/openhands/integrations/templates/resolver/gitlab/issue_comment_conversation_instructions.j2
@@ -0,0 +1,18 @@
+You are requested to fix issue number #{{ issue_number }} in a repository.
+
+A comment on the issue has been addressed to you.
+
+# Steps to Handle the Comment
+
+1. Address the comment. Use the GitLab API to read issue title, body, and comments if you need more context
+2. For all changes to actual application code (e.g. in Python or Javascript), add an appropriate test to the testing directory to make sure that the issue has been fixed
+3. Run the tests, and if they pass you are done!
+4. You do NOT need to write new tests if there are only changes to documentation or configuration files.
+
+When you're done, make sure to
+
+1. Re-read the issue title, body, and comments and make sure that you have successfully implemented all requirements.
+2. Use the `create_mr` tool to open a new MR
+3. Name the branch using `openhands/` as a prefix (e.g `openhands/update-readme`)
+4. The MR description should mention that it "fixes" or "closes" the issue number
+5. Make sure to leave the following sentence at the end of the MR description: `@{{ username }} can click here to [continue refining the MR]({{ conversation_url }})`
diff --git a/openhands/integrations/templates/resolver/gitlab/issue_comment_prompt.j2 b/openhands/integrations/templates/resolver/gitlab/issue_comment_prompt.j2
new file mode 100644
index 0000000000..352927cfd7
--- /dev/null
+++ b/openhands/integrations/templates/resolver/gitlab/issue_comment_prompt.j2
@@ -0,0 +1 @@
+{{ issue_comment }}
\ No newline at end of file
diff --git a/openhands/integrations/templates/resolver/gitlab/issue_labeled_conversation_instructions.j2 b/openhands/integrations/templates/resolver/gitlab/issue_labeled_conversation_instructions.j2
new file mode 100644
index 0000000000..17313595fd
--- /dev/null
+++ b/openhands/integrations/templates/resolver/gitlab/issue_labeled_conversation_instructions.j2
@@ -0,0 +1,12 @@
+Your tasking is to fix an issue in your repository. Do the following
+
+1. Read the issue body and comments using the GitLab API
+2. For all changes to actual application code (e.g. in Python or Javascript), add an appropriate test to the testing directory to make sure that the issue has been fixed
+3. Run the tests, and if they pass you are done!
+4. You do NOT need to write new tests if there are only changes to documentation or configuration files.
+
+When you're done, make sure to
+
+1. Use the `create_mr` tool to open a new MR
+2. The MR description should mention that it "fixes" or "closes" the issue number
+3. Make sure to leave the following sentence at the end of the MR description: `@{{ username }} can click here to [continue refining the MR]({{ conversation_url }})`
diff --git a/openhands/integrations/templates/resolver/gitlab/issue_labeled_prompt.j2 b/openhands/integrations/templates/resolver/gitlab/issue_labeled_prompt.j2
new file mode 100644
index 0000000000..eece89fec2
--- /dev/null
+++ b/openhands/integrations/templates/resolver/gitlab/issue_labeled_prompt.j2
@@ -0,0 +1 @@
+Please fix issue number #{{ issue_number }} in your repository.
\ No newline at end of file
diff --git a/openhands/integrations/templates/resolver/gitlab/mr_update_conversation_instructions.j2 b/openhands/integrations/templates/resolver/gitlab/mr_update_conversation_instructions.j2
new file mode 100644
index 0000000000..33813825e8
--- /dev/null
+++ b/openhands/integrations/templates/resolver/gitlab/mr_update_conversation_instructions.j2
@@ -0,0 +1,21 @@
+You are checked out to branch {{ branch_name }}, which has an open MR #{{ mr_number }}.
+A comment on the MR has been addressed to you. Do NOT respond to this comment via the GitLab API.
+
+{% if file_location %} The comment is in the file `{{ file_location }}` on line #{{ line_number }}{% endif %}.
+
+# Steps to Handle the Comment
+
+## Understand the MR Context
+Use the GitLab API to:
+ 1. Retrieve the diff against main to understand the changes
+ 2. Fetch the MR body and the linked issue for context
+
+## Process the Comment
+If it's a question:
+ 1. Answer the question asked
+ 2. DO NOT leave any comments on the MR
+
+If it requests a code update:
+ 1. Modify the code accordingly in the current branch
+ 2. Push the changes to update the MR
+ 3. DO NOT leave any comments on the MR
diff --git a/openhands/integrations/templates/resolver/gitlab/mr_update_prompt.j2 b/openhands/integrations/templates/resolver/gitlab/mr_update_prompt.j2
new file mode 100644
index 0000000000..4d26730c5f
--- /dev/null
+++ b/openhands/integrations/templates/resolver/gitlab/mr_update_prompt.j2
@@ -0,0 +1 @@
+{{ mr_comment }}