fix(swe-fast): clone repo before git_init so PR creation works#53
fix(swe-fast): clone repo before git_init so PR creation works#53williamhdean wants to merge 1 commit intoAgent-Field:mainfrom
Conversation
swe-fast was calling git_init on an empty directory (os.makedirs only, no clone) when repo_url was provided. git_init would do `git init` on the empty folder, leaving no remote. The subsequent PR step checks `if remote_url and cfg.enable_github_pr`, which was always False, so the PR was silently skipped and the agent worked on invented code instead of the actual repo. Fix: mirror the clone logic from swe_af/app.py — git clone on first run, fetch + reset to default branch on subsequent runs, re-clone as fallback on reset failure. Also add env_file: .env to the swe-fast Docker service so GH_TOKEN and other API keys are sourced from .env rather than requiring them to be exported in the host shell at docker compose up time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Billy seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
reviewing, in the meantime if you could sign the CLA as well! |
| if effective_repo_url and not os.path.exists(git_dir): | ||
| app.note(f"Cloning {effective_repo_url} → {repo_path}", tags=["fast_build", "clone"]) | ||
| os.makedirs(repo_path, exist_ok=True) | ||
| clone_result = subprocess.run( |
There was a problem hiding this comment.
CI failure is from this PR — test_repo_url_without_repo_path_auto_derives_repo_path patches os.makedirs but not subprocess.run, so this hits real git clone against /workspaces/my-project (permission denied on CI, remote-not-found locally). Either patch swe_af.fast.app.subprocess.run in that test or short-circuit the clone branch by pre-creating the .git dir in tmp_path and pointing repo_path there.
| ["git", "clone", effective_repo_url, repo_path], | ||
| capture_output=True, | ||
| text=True, | ||
| ) |
There was a problem hiding this comment.
Minor: subprocess.run is synchronous and blocks the event loop for the full clone duration (can be tens of seconds on large repos). Parent swe_af/app.py has the same pattern, so matching it is fine — just flagging for a follow-up (asyncio.create_subprocess_exec or asyncio.to_thread).
Fixes #52
Summary
swe_af/fast/app.py: Add clone logic beforerun_git_init. Whenrepo_urlis provided and.gitdoes not exist,git clonethe repo. On subsequent runs,fetch + reset --hardto the default branch (re-clone on failure). This ensuresremote_urlis populated so theenable_github_prgate passes.docker-compose.yml: Addenv_file: .envto theswe-fastservice soGH_TOKENand other API keys are sourced from.envrather than requiring them to be exported in the host shell.Test plan
swe-fastbuild endpoint with arepo_urlpointing to a real GitHub repoGH_TOKENis available inside the container without manual shell export🤖 Generated with Claude Code