Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Fix: Use repository's default branch for PR base instead of hardcoded 'main' (#1160)

Mahshooq Zubair8e481be6542d
diff --git a/sweagent/run/hooks/open_pr.py b/sweagent/run/hooks/open_pr.py
index d77b5017..918db2b7 100644
--- a/sweagent/run/hooks/open_pr.py
+++ b/sweagent/run/hooks/open_pr.py
@@ -97,13 +97,14 @@ def open_pr(*, logger, token, env: SWEEnv, github_url, trajectory, _dry_run: boo
)
body += "\n\n" + format_trajectory_markdown(trajectory, char_limit=60_000)
api = GhApi(token=token)
+ default_branch = api.repos.get(owner, repo).default_branch
if not _dry_run:
args = dict(
owner=owner,
repo=repo,
title=f"SWE-agent[bot] PR to fix: {issue.title}",
head=head,
- base="main",
+ base=default_branch,
body=body,
draft=True,
)