Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions src/response_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<details><summary>View Aider Output</summary>\n\n```\n{aider_output}\n```\n</details>"
# 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<details><summary>View Aider Output</summary>\n\n```\n{aider_output}\n```\n</details>"
else:
# Write response even when no changes were made
write_str = f"Aider did not make any changes:\n<details><summary>View Aider Output</summary>\n\n```\n{aider_output}\n```\n</details>"
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)
Expand Down Expand Up @@ -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))
Expand All @@ -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<details><summary>View Aider Output</summary>\n\n```{aider_output}```\n</details>"
f"Aider output:\n<details><summary>View Aider Output</summary>\n\n```\n{aider_output}\n```\n</details>"
# 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']}*"
Expand Down Expand Up @@ -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)
Expand Down