Skip to content

Commit 0f19ce4

Browse files
committed
Fix sending changes back to rework if nothing got applied.
Also, try to tone down LLMs se of INPUT_REQUIRED.
1 parent b668088 commit 0f19ce4

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

pilot/helpers/agents/CodeMonkey.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from helpers.Agent import Agent
99
from helpers.files import get_file_contents
1010
from const.function_calls import GET_FILE_TO_MODIFY, REVIEW_CHANGES
11+
from logger.logger import logger
1112

1213
from utils.exit import trace_code_event
1314
from utils.telemetry import telemetry
@@ -268,17 +269,27 @@ def review_change(
268269

269270
if len(hunks_to_apply) == len(hunks):
270271
print("Applying entire change")
272+
logger.info(f"Applying entire change to {file_name}")
271273
return new_content, None
274+
272275
elif len(hunks_to_apply) == 0:
273-
print(f"Rejecting entire change with reason: {llm_response['review_notes']}")
274-
# If everything can be safely ignoring, it's probably because the files already implement the changes
275-
# from previous tasks (which can happen often). Insisting on a change here is likely to cause problems.
276-
return old_content, None
276+
if hunks_to_rework:
277+
print(f"Requesting rework for {len(hunks_to_rework)} changes with reason: {llm_response['review_notes']}")
278+
logger.info(f"Requesting rework for {len(hunks_to_rework)} changes to {file_name} (0 hunks to apply)")
279+
return old_content, review_log
280+
else:
281+
# If everything can be safely ignored, it's probably because the files already implement the changes
282+
# from previous tasks (which can happen often). Insisting on a change here is likely to cause problems.
283+
print(f"Rejecting entire change with reason: {llm_response['review_notes']}")
284+
logger.info(f"Rejecting entire change to {file_name} with reason: {llm_response['review_notes']}")
285+
return old_content, None
277286

278287
print("Applying code change:\n" + diff_log)
288+
logger.info(f"Applying code change to {file_name}:\n{diff_log}")
279289
new_content = self.apply_diff(file_name, old_content, hunks_to_apply, new_content)
280290
if hunks_to_rework:
281291
print(f"Requesting rework for {len(hunks_to_rework)} changes with reason: {llm_response['review_notes']}")
292+
logger.info(f"Requesting further rework for {len(hunks_to_rework)} changes to {file_name}")
282293
return new_content, review_log
283294
else:
284295
return new_content, None

pilot/prompts/development/implement_changes.prompt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ the full contents of the updated file, without skipping over any content
1111
------------------------end_of_format---------------------------
1212

1313
**IMPORTANT**: Your reply MUST NOT omit any code in the new implementation or substitute anything with comments like `// .. rest of the code goes here ..` or `# insert existing code here`, because I will overwrite the existing file with the content you provide. Output ONLY the content for this file, without additional explanation, suggestions or notes. Your output MUST start with ``` and MUST end with ``` and include only the complete file contents.
14-
**IMPORTANT**: If the user must configure something manually, mark the line that needs user configuration with `INPUT_REQUIRED {input_description}` comment, where `input_description` is a description of what needs to be added here by the user. Use appropriate syntax for comments in the file you're saving (for example `// INPUT_REQUIRED {input_description}` in JavaScript). If the file type doesn't support comments (eg JSON), don't add any.
14+
**IMPORTANT**: Avoid hardcoding configuration values (eg. port, database url or server secret string) in code. Instead, use appropriate settings file (for example `.env`) for all user-configurable settings. Mark line(s) that need user configuration with `INPUT_REQUIRED {input_description}` comment, where `input_description` is a description of what needs to be added in that line by the user. Use appropriate syntax for comments in the file you're saving (for example `# INPUT_REQUIRED {input_description}` in `.env`). If the file type doesn't support comments (eg JSON), don't add any.
1515

1616
{{ logs_and_error_handling }}

0 commit comments

Comments
 (0)