SWE-AF icon indicating copy to clipboard operation
SWE-AF copied to clipboard

bug(swe-fast): repo never cloned — git_init works on empty dir, PR creation always skipped

Open williamhdean opened this issue 7 months ago • 2 comments

Bug

When swe-fast is called with a repo_url, it derives repo_path from the URL and calls os.makedirs() — but never clones the repo. run_git_init then finds an empty directory and runs git init, creating a local repo with no remote.

Because git remote get-url origin fails on a fresh git init, remote_url comes back empty. The PR creation gate at the end of build() is:

if remote_url and cfg.enable_github_pr:

This is always False, so the PR step is silently skipped on every run. As a side effect, the coding agents work against an empty workspace instead of the actual codebase, so they invent code from scratch.

Root cause

swe_af/fast/app.py lines 80–85 (before this fix):

if effective_repo_url and not repo_path:
    repo_path = f"/workspaces/{_repo_name_from_url(effective_repo_url)}"
if not repo_path:
    raise ValueError("Either repo_path or repo_url must be provided")

os.makedirs(repo_path, exist_ok=True)  # creates dir but never clones!

The parent swe_af/app.py has the correct clone logic but it was never ported to the fast variant.

Additional issue

The swe-fast Docker service in docker-compose.yml was missing env_file: .env, so GH_TOKEN (and other API keys) were only picked up if already exported in the host shell — silently empty otherwise.

Fix

See linked PR. Mirrors the clone/reset/re-clone logic from swe_af/app.py into swe_af/fast/app.py, and adds env_file: .env to the swe-fast Docker service.

williamhdean avatar Apr 21 '26 18:04 williamhdean

Cc @AbirAbbas

santoshkumarradha avatar Apr 21 '26 20:04 santoshkumarradha

Fix is up in #150. swe-fast.build now clones repo_url before run_git_init (and fetch/resets — or re-clones — an existing workspace), so remote_url is populated and the enable_github_pr gate is reachable again; the Go fast node had the identical MkdirAll-and-no-clone path, so it got the same fix.

Validated by running the real build() against a public repo with the agent calls stubbed: before, run_git_init saw an empty directory, remote_url was empty and run_github_pr was never called; after, the workspace holds the clone, git remote get-url origin returns the URL and the PR step runs. The env_file: .env half of your report was fixed on main separately in the meantime.

AbirAbbas avatar Sep 21 '26 17:09 AbirAbbas