diff --git a/src/response_agent.py b/src/response_agent.py index 83cd58e..366d3cc 100644 --- a/src/response_agent.py +++ b/src/response_agent.py @@ -689,17 +689,21 @@ def process_issue( # Then run aider with the generated command aider_output = run_aider(response, repo_path) - # Push changes - push_success, err_msg = push_changes_with_authentication( - repo_path, - pr, - branch_name) - - if not push_success: - return False, f"Failed to push changes: {err_msg}" - - # Write response - write_str = f"Applied changes based on comment:\n
View Aider Output\n\n```\n{aider_output}\n```\n
" + # Push changes if Aider made any (if output doesn't contain the "No changes" message) + if "No changes were made by Aider" not in aider_output: + push_success, err_msg = push_changes_with_authentication( + repo_path, + pr, + branch_name) + + if not push_success: + return False, f"Failed to push changes: {err_msg}" + + # Write response with success message + write_str = f"Applied changes based on comment:\n
View Aider Output\n\n```\n{aider_output}\n```\n
" + else: + # Write response even when no changes were made + write_str = f"Aider did not make any changes:\n
View Aider Output\n\n```\n{aider_output}\n```\n
" signature = f"\n\n---\n*This response was automatically generated by blech_bot using model {llm_config['model']}*" # Clean the response first to remove any existing signatures write_str = clean_response(write_str) @@ -758,13 +762,19 @@ def process_issue( client = get_github_client() repo = get_repository(client, repo_name) - # Push changes with authentication - push_success, err_msg = push_changes_with_authentication( - repo_path, - issue, - branch_name - ) + # Only push changes if Aider made any + if "No changes were made by Aider" not in aider_output: + # Push changes with authentication + push_success, err_msg = push_changes_with_authentication( + repo_path, + issue, + branch_name + ) + + if not push_success: + return False, f"Failed to push changes: {err_msg}" + # Create PR even if no changes were made (for debugging purposes) pr_url = create_pull_request_from_issue(issue, repo_path) pr_number = pr_url.split('/')[-1] pull = repo.get_pull(int(pr_number)) @@ -778,12 +788,9 @@ def process_issue( # Mark issue with label "under_development" issue.add_to_labels("under_development") - if not push_success: - return False, f"Failed to push changes: {err_msg}" - - # write_issue_response(issue, "Generated edit command:\n" + response) + # Always include the Aider output in the PR comment write_str = f"Generated edit command:\n---\n{response}\n\n" + \ - f"Aider output:\n
View Aider Output\n\n```{aider_output}```\n
" + f"Aider output:\n
View Aider Output\n\n```\n{aider_output}\n```\n
" # Clean the response first to remove any existing signatures write_str = clean_response(write_str) signature = f"\n\n---\n*This response was automatically generated by blech_bot using model {llm_config['model']}*" @@ -862,7 +869,8 @@ def run_aider(message: str, repo_path: str) -> str: # Check if there are any changes updated_commit = git.Repo(repo_path).head.object.hexsha if current_commit == updated_commit: - raise RuntimeError("No changes made by Aider") + # Return a specific message instead of raising an error + return "No changes were made by Aider. This could be because the requested changes were already implemented, or because Aider couldn't understand how to implement the requested changes." # Return to original directory os.chdir(original_dir)