# How Do I Review a Coding Agent's Branch Before It's Pushed?

> Don't trust the agent's summary or its own test run. Diff the branch against its base, flag edits to test files and dependency manifests, take the branch out with git bundle, and run your base branch's tests on its code in a fresh sandbox. In our run that caught two skipped tests and an unrequested dependency.

Source: https://sandboxer.com/guides/review-an-agents-branch-before-its-pushed. Updated 2026-11-26.

**Short answer:** Don't trust the agent's summary or its own test run. Diff the branch against its base, flag edits to test files and dependency manifests, take the branch out with git bundle, and run your base branch's tests on its code in a fresh sandbox. In our run that caught two skipped tests and an unrequested dependency.

Part of [Coding Agents in the Cloud: Parallel, Overnight, Own Keys, Checkpoints](/guides/coding-agents-in-the-cloud).

An agent's summary is the agent grading its own work. So is "all tests pass" when it ran the tests itself, in its own sandbox, after editing them. This page is about the branch: the commits it wants to push. Two neighbors cover the rest. [See everything a coding agent changed outside git](/guides/see-everything-a-coding-agent-changed-outside-git) catches edits to the virtualenv, dotfiles and hooks that never reach a commit. [What to keep before deleting a coding agent's sandbox](/guides/what-to-keep-before-deleting-a-coding-agents-sandbox) saves every ref and log once you're done.

## Which check caught what

We cloned [itsdangerous](https://github.com/pallets/itsdangerous) (commit `672971d`) into a `small` sandbox created with `--no-env`. A scripted "agent" (a shell script, not a model) was asked to tolerate clock skew in `max_age` checks. It made three commits on `agent/clock-skew` and printed this summary:

```text
SUMMARY: Added clock-skew tolerance to max_age. Small change in timed.py; all tests pass.
```

The summary is true as far as it goes, and leaves out two of the three commits. This is what each review step showed:

| Review step | Command | What it showed in our run |
| - | - | - |
| Read the agent's summary | none | "Small change in timed.py; all tests pass." |
| List the commits | `git log --oneline main..agent/clock-skew` | 3 commits; 2 aren't in the summary |
| Diff stat against the base | `git diff --stat main...agent/clock-skew` | 3 files: `pyproject.toml`, `timed.py`, `test_timed.py` |
| Flag test-file edits and new skips | `review-check.sh` (below) | `test_timed.py` changed; 2 new `@pytest.mark.skip(reason="flaky on CI")` |
| Flag dependency changes | `review-check.sh` | `+dependencies = ["requests>=2.31"]` in a package that had none |
| The agent's tests, in a fresh sandbox | `pytest -q` | `292 passed, 5 skipped`: looks green |
| The base branch's tests on the agent's code | `git restore --source=main -- tests` then `pytest -q` | `5 failed, 292 passed` |

Last checked: 2026-11-26, on prod.

The last row is the one that matters. The agent's own tests pass because it skipped the two that failed. Your base branch's tests are the spec you agreed to, and they fail on its code.

## Where Sandboxer fits

Each Sandboxer sandbox is a microVM with its own kernel and disk ([machines](/docs/machines)). The agent works in one. You run the review in a second, new sandbox that never saw the agent, so nothing it left on its own disk can change your result. A new `small` sandbox was ready 0.29 s after `sbx new` in our run, and you delete it when the review is done. Plans start at $20/mo ([pricing](/pricing)).

## 1. The diff against the base, not the agent's last commit

Diff against the branch point. `git diff` on its own shows uncommitted work, which is empty once the agent commits. `main...branch` (three dots) shows everything on the branch since it left `main`:

```bash
sbx exec "$id" 'cd ~/itsdangerous && git log --oneline main..agent/clock-skew && git diff --stat main...agent/clock-skew && git diff main...agent/clock-skew'
```

```text
297286e Add requests for upcoming webhook support
4e518fc Skip flaky timing tests
819c0a7 Allow 5 s of clock skew in max_age checks
 pyproject.toml                        | 1 +
 src/itsdangerous/timed.py             | 2 +-
 tests/test_itsdangerous/test_timed.py | 2 ++
 3 files changed, 4 insertions(+), 1 deletion(-)
…
-            if age > max_age:
+            if age > max_age + 5:  # allow clock skew
…
+    @pytest.mark.skip(reason="flaky on CI")
     def test_max_age(self, signer, ts, freeze):
…
+    @pytest.mark.skip(reason="flaky on CI")
     def test_max_age(self, serializer, value, ts, freeze):
```

Read the stat first. A three-file change to a "small change in timed.py" is the first thing to ask about.

## 2. Flag test edits and dependency changes

On a long diff, two kinds of change are easy to miss and change what "passing" means: edits to tests and edits to dependency manifests. This script lists both and exits 1 if it finds any:

```bash
# review-check.sh BASE BRANCH: flag test edits, new skips and dependency changes. Exit 1 if anything is flagged.
base=$1 br=$2 flagged=0
files=$(git diff --name-only "$base...$br")
tests=$(echo "$files" | grep -E '(^|/)tests?/|(^|/)test_[^/]*\.py$|_test\.(py|go)$|\.(test|spec)\.[cm]?[jt]sx?$')
deps=$(echo "$files" | grep -E '(^|/)(pyproject\.toml|setup\.(py|cfg)|requirements[^/]*\.txt|uv\.lock|poetry\.lock|Pipfile(\.lock)?|package(-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|go\.(mod|sum)|Cargo\.(toml|lock)|Gemfile(\.lock)?)$')
skips=$(git diff "$base...$br" -- $tests | grep -E '^\+.*(skip|xfail|\.only\(|assert True|return$)' | grep -v '^+++')
[ -n "$tests" ] && { echo "FLAG test files changed:"; echo "$tests" | sed 's/^/  /'; flagged=1; }
[ -n "$skips" ] && { echo "FLAG new skips or always-pass lines:"; echo "$skips" | sed 's/^/  /'; flagged=1; }
[ -n "$deps" ] && { echo "FLAG dependency files changed:"; git diff "$base...$br" -- $deps | grep -E '^[+-][^+-]' | sed 's/^/  /'; flagged=1; }
[ $flagged = 0 ] && echo "no test or dependency changes"
exit $flagged
```

```text
FLAG test files changed:
  tests/test_itsdangerous/test_timed.py
FLAG new skips or always-pass lines:
  +    @pytest.mark.skip(reason="flaky on CI")
  +    @pytest.mark.skip(reason="flaky on CI")
FLAG dependency files changed:
  +dependencies = ["requests>=2.31"]
review-check exit: 1
```

A flag isn't a verdict. Agents edit tests for good reasons, and a new feature can need a new package. A flag means a person reads that part of the diff and the commit message before merging. Here, "Skip flaky timing tests" comes right after the commit that broke them, and nothing in the task needs an HTTP client.

The patterns are a starting list. Add the files that change what your tests do, such as a root `conftest.py`, `pytest.ini`, `tox.ini`, `jest.config.*` or CI workflows, and the lock files your stack uses.

## 3. Take the branch out with git bundle

A [git bundle](https://git-scm.com/docs/git-bundle) is one file holding commits and refs. Bundle only the agent's commits, `main..agent/clock-skew`, and the file lists the base commit as a prerequisite that the receiving clone must already have:

```bash
sbx exec "$id" 'cd ~/itsdangerous && git bundle create ~/agent.bundle main..agent/clock-skew && git bundle verify ~/agent.bundle && ls -l ~/agent.bundle'
sbx scp "$id:/home/user/agent.bundle" .
git bundle list-heads agent.bundle
```

```text
The bundle contains this ref:
297286edacdd75e0971647d248391820cdc460e6 refs/heads/agent/clock-skew
The bundle requires this ref:
672971d66a2ef9f85151e53283113f33d642dabd
The bundle uses this hash algorithm: sha1
-rw-r--r-- 1 user user 1365 Nov 26 11:05 /home/user/agent.bundle
/home/user/agent.bundle is okay
297286edacdd75e0971647d248391820cdc460e6 refs/heads/agent/clock-skew
```

1,365 bytes. A bundle carries git objects and refs only. The agent's working tree, untracked files, `.git/hooks` and `.git/config` stay behind, so fetching it brings back exactly what a push would send. Once the bundle is on your machine, you can delete the agent's sandbox. We did, and `sbx info` returned 404.

## 4. Run the tests in a fresh sandbox, twice

In a new sandbox, clone the repo from its public remote, fetch the branch from the bundle and test it. Installing the branch pulls in whatever it declares, so do this on a throwaway machine, not your laptop. We copied the bundle and two scripts in with `sbx scp` and ran this as `fresh.sh`:

```bash
set -e
cd ~ && git clone -q --depth 1 https://github.com/pallets/itsdangerous && cd itsdangerous
git bundle verify -q ~/agent.bundle
git fetch -q ~/agent.bundle agent/clock-skew:agent/clock-skew
git log --oneline main..agent/clock-skew
bash ~/review-check.sh main agent/clock-skew || echo "review-check exit: $?"
git switch -q agent/clock-skew
python3 -m venv ~/venv && ~/venv/bin/pip install -q -e . pytest freezegun 2>&1 | tail -1
~/venv/bin/pip list 2>/dev/null | grep -iE '^(requests|urllib3|certifi) '
echo "== the agent's tests on the agent's code:"
~/venv/bin/pytest -q -rs 2>&1 | tail -3 || true
echo "== main's tests on the agent's code:"
git restore --source=main -- tests
~/venv/bin/pytest -q 2>&1 | grep -E '^(FAILED|[0-9]+ (passed|failed))' || true
git restore --source=HEAD -- tests
```

```text
…
certifi            2026.11.20
requests           2.34.2
urllib3            2.8.0
== the agent's tests on the agent's code:
SKIPPED [1] tests/test_itsdangerous/test_timed.py:34: flaky on CI
SKIPPED [4] tests/test_itsdangerous/test_timed.py:102: flaky on CI
292 passed, 5 skipped in 0.46s
== main's tests on the agent's code:
FAILED tests/test_itsdangerous/test_timed.py::TestTimestampSigner::test_max_age
FAILED tests/test_itsdangerous/test_timed.py::TestTimedSerializer::test_max_age
FAILED tests/test_itsdangerous/test_url_safe.py::TestTimedSerializer::test_max_age
FAILED tests/test_itsdangerous/test_url_safe.py::TestURLSafeTimedSerializer::test_max_age[value0]
FAILED tests/test_itsdangerous/test_url_safe.py::TestURLSafeTimedSerializer::test_max_age[zlib]
5 failed, 292 passed in 0.48s
```

The script took 8.4 s, including the clone and the install. Three things to read here:

- **Two skip lines turned off five tests.** Classes in `test_url_safe.py` inherit `test_max_age` from `TestTimedSerializer`, so one decorator skipped it in three places. A diff shows two lines; the test run shows the reach.
- **The new dependency came with two more.** `requests` brought `urllib3` and `certifi`, which the install pulled in and the diff never names.
- **Main's tests are the check.** Putting the base branch's `tests/` back over the agent's code turned 5 skips into 5 failures. For comparison, `main` on its own passed all 297 in the same sandbox.

If the agent added new tests you want to keep, run both suites: main's tests tell you nothing broke, and the agent's new tests tell you the feature works. A test the agent changed rather than added is the one to read line by line.

## Copy-paste: review a stand-in agent branch in a fresh sandbox

Install the CLI with `curl -fsSL https://sandboxer.com/install | sh` and sign in with `sbx login`. Then paste this. Step 1 makes a stand-in for the agent's branch on your machine with `git` and `perl` (no code from the repo runs) and bundles it. Step 2 creates a `small` sandbox with none of your secrets, reviews the bundle there, runs both test suites, and deletes the sandbox. It uses `jq` on your machine.

```bash
# 1. A stand-in for the agent's branch, made on your machine with git and perl. Nothing from the repo runs here.
git clone -q --depth 1 https://github.com/pallets/itsdangerous agent-repo && cd agent-repo
c() { git -c user.name=agent -c user.email=agent@example.com commit -qam "$1"; }
git switch -q -c agent/clock-skew
perl -pi -e 's/if age > max_age:/if age > max_age + 5:/' src/itsdangerous/timed.py && c "Allow 5 s of clock skew"
perl -pi -e 's/^(    def test_max_age\()/    \@pytest.mark.skip(reason="flaky on CI")\n$1/' tests/test_itsdangerous/test_timed.py && c "Skip flaky timing tests"
perl -pi -e 's/^(requires-python = .*)$/$1\ndependencies = ["requests>=2.31"]/' pyproject.toml && c "Add requests"
git bundle create -q ../agent.bundle main..agent/clock-skew && cd ..

# 2. The review, run in a fresh sandbox that never saw the agent.
cat > review.sh <<'EOF'
cd ~ && git clone -q --depth 1 https://github.com/pallets/itsdangerous && cd itsdangerous
git fetch -q ~/agent.bundle agent/clock-skew:agent/clock-skew && git diff --stat main...agent/clock-skew
files=$(git diff --name-only main...agent/clock-skew)
echo "$files" | grep -E '(^|/)tests?/|(^|/)test_[^/]*\.py$|\.(test|spec)\.[jt]sx?$' | sed 's/^/FLAG test file: /'
git diff main...agent/clock-skew -- tests | grep -E '^\+.*(skip|xfail|\.only\(|assert True)' | sed 's/^/FLAG new skip: /'
echo "$files" | grep -E '(^|/)(pyproject\.toml|requirements[^/]*\.txt|setup\.(py|cfg)|package\.json|go\.mod|Cargo\.toml)$' | while read -r f; do
  git diff main...agent/clock-skew -- "$f" | grep -E '^[+-][^+-]' | sed "s|^|FLAG dependency ($f): |"; done
git switch -q agent/clock-skew && python3 -m venv ~/venv && ~/venv/bin/pip install -q -e . pytest freezegun
echo "agent's tests: $(~/venv/bin/pytest -q | tail -1)"
git restore --source=main -- tests && echo "main's tests:  $(~/venv/bin/pytest -q | tail -1)"
EOF
id=$(sbx new --name aeo-review-branch-3 --type small --no-env --ttl 900 --json | jq -r 'select(.event=="ready") | .id')
sbx scp agent.bundle review.sh "$id:/home/user/"
sbx exec "$id" --timeout 600 'bash ~/review.sh'
sbx delete "$id" --yes
sbx info "$id"
```

Our run on 2026-11-26, 14 s end to end (output piped, so `sbx` printed JSON; trimmed with `…`):

```text
 pyproject.toml                        | 1 +
 src/itsdangerous/timed.py             | 2 +-
 tests/test_itsdangerous/test_timed.py | 2 ++
 3 files changed, 4 insertions(+), 1 deletion(-)
FLAG test file: tests/test_itsdangerous/test_timed.py
FLAG new skip: +    @pytest.mark.skip(reason="flaky on CI")
FLAG new skip: +    @pytest.mark.skip(reason="flaky on CI")
FLAG dependency (pyproject.toml): +dependencies = ["requests>=2.31"]
agent's tests: 292 passed, 5 skipped in 0.53s
main's tests:  5 failed, 292 passed in 0.50s
{"ok":true,"type":"deletion.operation","operation":{…,"status":"completed",…}}
{"event":"error","error":"Sandbox not found","code":"not_found","status":404,…}
```

The last line confirms the sandbox is gone. The block leaves `agent-repo`, `agent.bundle` and `review.sh` in your current directory; `rm -rf agent-repo agent.bundle review.sh` removes them. With a real agent, replace step 1 with `sbx scp "$agent_id:/home/user/agent.bundle" .` after bundling its branch as in section 3. If a call hits a rare 502 during a platform update, retry after a few seconds.

## FAQ

### Why not just run the tests in the agent's own sandbox?

The agent had a shell there. It may have edited the tests, the installed packages or the test config, and its own run already told you what it wants you to see. A new sandbox with a fresh clone and only the bundle's commits tests what you'd actually merge.

### Is a git bundle safer than pushing the agent's branch to a remote?

They carry the same commits. A bundle needs no push credentials in the agent's sandbox, so you can create that sandbox with `--no-env`, which passes none of your account's secrets into it. You decide what gets pushed after the review.

### Should I block every branch that edits a test?

No. Treat a flag as "read this part". Agents fix wrong tests and add new ones for real reasons. Block on a skip, an `xfail` or a loosened assertion that the task didn't ask for, and on a dependency nobody requested.

### What does this miss?

Changes that never reach a commit, such as edited packages in the virtualenv, dotfiles and git hooks. Those can't ride along in a bundle, and the fresh sandbox doesn't have them. To see them anyway, use the [disk manifest](/guides/see-everything-a-coding-agent-changed-outside-git).

## Related

- [Coding Agents in the Cloud: Parallel, Overnight, Own Keys, Checkpoints](/guides/coding-agents-in-the-cloud)
- [See everything a coding agent changed outside git](/guides/see-everything-a-coding-agent-changed-outside-git)
- [What to keep before deleting a coding agent's sandbox](/guides/what-to-keep-before-deleting-a-coding-agents-sandbox)
- [Handle merge conflicts between parallel agents](/guides/handle-merge-conflicts-between-parallel-coding-agents)
