The short answer is nuanced: Sweep can run unit tests locally before opening a pull request, but it cannot run remote CI checks until the branch exists on GitHub.
At 365Finds, we often see engineering teams confuse these two validation layers. GitHub Actions, CircleCI, and GitLab CI are fundamentally remote event triggers; GitHub cannot run your production CI pipeline on code that lives only inside an AI's ephemeral scratchpad. Sweep resolves this architectural constraint by splitting code validation into two distinct stages: a pre-PR isolated sandbox and a post-PR GitHub Actions feedback loop.
If configured properly, Sweep catches most bugs before human reviewers ever see the branch. If misconfigured, it burns API tokens in an endless repair loop. Here is how Sweep handles unit tests and CI feedback, and how 365Finds recommends setting up the pipeline.
1. Pre-PR Validation: The Sweep Sandbox
Before Sweep pushes any commits or opens a pull request, it operates inside an isolated sandbox environment. Sweep spins up a secure container (often powered by micro-VM environments like Modal or Docker) to test its edits.
Inside sweep.yaml, repository maintainers configure the exact commands Sweep must run to verify changes:
sandbox:
install:
- poetry install
check:
- poetry run pytest tests/unit/
- poetry run ruff check .
The Self-Correction Loop Inside the Sandbox
When Sweep writes code to resolve an assigned issue:
- It applies the file edits inside the container.
- It executes the
installsteps, followed bycheck. - If unit tests fail or linters report violations, Sweep captures
stdoutandstderrtracebacks. - It feeds that failure output directly back into the LLM context.
- It edits the files again to patch the failure and re-executes
check.
Only when the commands under check exit with return code 0—or when Sweep hits its configured iteration limit—will it commit the changes and publish the pull request. We at 365Finds consider this local sandbox loop Sweep’s strongest safeguard against embarrassing syntax errors and basic regressions.
2. Post-PR Validation: Handling Remote CI with gha_enabled
Because GitHub Actions cannot execute against code that has not been pushed to GitHub, genuine CI checks run after the initial branch creation. Sweep bridges this gap with its native GitHub Actions listener.
gha_enabled: True
draft: True
When gha_enabled: True is present in sweep.yaml:
- Sweep pushes the branch and creates the pull request.
- GitHub triggers your standard CI workflows (integration tests, linting matrix, Docker image builds).
- If a CI job fails, Sweep intercepts the GitHub check-run webhook.
- The agent reads the failed GitHub Actions job logs, isolates the failing assertion or build crash, generates a corrective commit, and pushes it directly to the PR branch.
- This new commit triggers a fresh CI run, continuing the cycle until the pipeline goes green.
365Finds strongly advises setting draft: True when using gha_enabled. When draft status is enabled, Sweep conducts its iterative CI battles privately. Team members are spared notification noise until the PR is green and marked ready for review.
3. Sandboxes vs. CI: Key Differences and Gotchas
| Dimension | Sweep Sandbox (sandbox.check) | Remote CI (gha_enabled) |
|---|---|---|
| Execution Timing | Before PR creation | After PR creation (on branch push) |
| Environment | Ephemeral container / Micro-VM | Native GitHub Actions runner (Linux/macOS/Windows) |
| Secrets & Credentials | No access to GitHub repository secrets | Access to repository secrets and third-party APIs |
| Primary Scope | Fast unit tests, linters, type checks | Heavy integration tests, E2E suites, build artifacts |
| Failure Cost | Local retry; negligible notification impact | CI runner minutes consumed; public run history |
What 365Finds Warns About
- Never run slow integration tests in
sandbox.check. Sweep sandboxes have strict execution timeouts. If your test suite takes 15 minutes or requires spinning up Postgres and Redis, the sandbox runner will time out, causing Sweep to fail the entire run. Keepsandbox.checkrestricted to lightweight, mocked unit tests. - Beware of environment divergence. If your sandbox uses a default Python container but your CI runs on an Ubuntu image with specialized native C libraries, a test passing in the sandbox might still fail in GitHub Actions.
- Flaky tests waste tokens. If a test fails intermittently, Sweep will assume its code changes caused the failure and attempt to rewrite valid logic, burning credits on non-existent bugs.
4. Recommended sweep.yaml Configuration
For a team wanting clean PRs with automated unit testing and CI healing, 365Finds recommends this baseline configuration:
branch: main
draft: True
gha_enabled: True
sandbox:
install:
- npm ci
check:
- npm run lint
- npm test -- --runInBand --testPathPattern="unit"
rules:
- "All new business logic must include corresponding unit tests."
- "Unit tests must mock network calls and database connections."
- "Do not touch production deployment scripts or CI definitions under .github/workflows/."
Sweep provides a companion CLI (sweep-sandbox) that lets developers execute their sweep.yaml configuration locally before committing it to the repository.