Skip to content

Commit 30b7eab

Browse files
committed
Prompt updates for resolver accuracy
1 parent ca9beb9 commit 30b7eab

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
You are OpenHands agent, a helpful AI assistant that can interact with a computer to solve tasks.
2-
<IMPORTANT></IMPORTANT>

openhands/events/replay.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ def replay_enhance_action(state: State, is_workspace_repo: bool) -> Action | Non
5454
logger.info(f'[REPLAY] latest_user_message id is {latest_user_message.id}')
5555
# 2. Check if it has a recordingId.
5656
recording_id = scan_recording_id(latest_user_message.content)
57-
logger.debug(
58-
f'DDBG Scanned for recording id: {latest_user_message.content}...'
59-
)
6057
if recording_id:
6158
# 3. Analyze recording and start the enhancement action.
6259
logger.info(
@@ -122,10 +119,12 @@ def handle_replay_enhance_observation(
122119
# start_location = result.get('startLocation', '')
123120
start_name = result.get('startName', '')
124121

125-
enhancement = f'There is a bug in {annotated_repo_path}:\n\n<BUG_REPORT>{comment_text}</BUG_REPORT>\n\nReproduction information from a recording of the problem is available in source comments.\nThe bug was reported at {start_name}. Start your investigation there. Then keep searching for related `reproduction step` comments and pay special attention to their contents, as they provide important data flow and type information.\n\nOnce done, propose necessary changes without implementing them.'
122+
# TODO: Move this to a prompt template file.
123+
enhancement = f'There is a bug in {annotated_repo_path}:\n\n{comment_text}\n\nReproduction information from a recording of the problem is available in source comments.\nThe bug was reported at {start_name}. Start your investigation there. Then keep searching for related `reproduction step` comments and pay special attention to their contents.\nOnce done, propose necessary changes, without implementing them.'
126124

127125
# Enhance:
128-
user_message.content = f'{original_prompt}\n\n{enhancement}'
126+
user_message.content = f'{enhancement}\n\n{original_prompt}'
127+
# user_message.content = enhancement
129128
logger.info(f'[REPLAY] Enhanced user prompt:\n{user_message.content}')
130129
return True
131130
else:
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
Please fix the following issue for the repository in /workspace.
2-
An environment has been set up for you to start working. You may assume all necessary tools are installed.
1+
Please fix this issue in `/workspace`.
32

4-
# Problem Statement
3+
<ISSUE_INFORMATION>
54
{{ body }}
5+
</ISSUE_INFORMATION>
66

7-
IMPORTANT: You should ONLY interact with the environment provided to you AND NEVER ASK FOR HUMAN HELP.
8-
You SHOULD INCLUDE PROPER INDENTATION in your edit commands.{% if repo_instruction %}
7+
You do NOT need to write new tests for code changes.
98

9+
{% if repo_instruction %}
1010
Some basic information about this repository:
1111
{{ repo_instruction }}{% endif %}
12-
13-
You do NOT need to write new tests for code changes.
14-
15-
When you think you have fixed the issue through code changes, please finish the interaction.

openhands/resolver/resolve_issue.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import re
99
import shutil
1010
import subprocess
11+
import traceback
1112
from typing import Any
1213
from uuid import uuid4
1314

@@ -445,6 +446,24 @@ async def resolve_issue(
445446
target_branch: Optional target branch to create PR against (for PRs).
446447
reset_logger: Whether to reset the logger for multiprocessing.
447448
"""
449+
450+
def exception_handler(_loop, context):
451+
exception = context.get('exception')
452+
if exception is not None:
453+
# We have an actual exception
454+
print(f'ERROR: {exception}')
455+
traceback.print_exception(
456+
type(exception), exception, exception.__traceback__
457+
)
458+
else:
459+
# No exception object; print the message and current stack
460+
message = context.get('message', 'Unknown error')
461+
print(f'ERROR: {message}')
462+
traceback.print_stack()
463+
464+
loop = asyncio.get_running_loop()
465+
loop.set_exception_handler(exception_handler)
466+
448467
issue_handler = issue_handler_factory(issue_type, owner, repo, token)
449468

450469
# Load dataset

0 commit comments

Comments
 (0)