-
Notifications
You must be signed in to change notification settings - Fork 106
Fix PR review agent multi-line suggestion alignment #1677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The PR review agent was making suggestions that spanned multiple lines but only specifying a single line number, causing misaligned suggestions. This adds documentation for using start_line and line parameters together when making multi-line comments or suggestions, with examples for both gh CLI and curl. Co-authored-by: openhands <[email protected]>
all-hands-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found two issues in the new documentation that need to be fixed: malformed JSON in the curl example and a missing API version header.
xingyaoww
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing multi-line suggestion with corrected JSON format.
| "body": "Consider this improvement:\\n\\n```suggestion\\n | ||
| first_line = \\"improved\\"\\nsecond_line = \\"code\\"\\n | ||
| third_line = \\"here\\"\\n```" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical Issue - Malformed JSON: This curl example has literal newlines embedded in the JSON string value, which creates invalid JSON. The line breaks after \n on lines 195-197 should not be there.
| "body": "Consider this improvement:\\n\\n```suggestion\\n | |
| first_line = \\"improved\\"\\nsecond_line = \\"code\\"\\n | |
| third_line = \\"here\\"\\n```" | |
| "body": "Consider this improvement:\\n\\n```suggestion\\nfirst_line = \\"improved\\"\\nsecond_line = \\"code\\"\\nthird_line = \\"here\\"\\n```" |
The entire body value should be on a single line with proper escape sequences.
The curl example had literal newlines embedded in the JSON string value, which creates invalid JSON. Fixed by putting the body value on a single line with proper escape sequences. Also simplified the example to use a 2-line suggestion (lines 10-11) with shorter variable names to fit within line length limits. Co-authored-by: openhands <[email protected]>
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
Problem
The PR review agent was making suggestions that spanned multiple lines but only specifying a single line number, causing misaligned suggestions. For example, when suggesting changes to two consecutive lines like:
The agent would only select line 119, but the suggestion contained two lines, resulting in a misaligned comment where the original lines and suggested lines didn't match up.
See this example: #1666 (comment)
Solution
Updated the PR review prompt to include documentation for using
start_lineandlineparameters together when making multi-line comments or suggestions.Changes
start_line,line,start_side, andsideparametersghCLI andcurlshowing how to make multi-line suggestionsTesting
This is a prompt-only change. The next time the PR review agent runs, it will have the updated instructions for handling multi-line suggestions correctly.
@xingyaoww can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:cee6223-pythonRun
All tags pushed for this build
About Multi-Architecture Support
cee6223-python) is a multi-arch manifest supporting both amd64 and arm64cee6223-python-amd64) are also available if needed