Two patches for the same bug both look reasonable, and both pass the one test case you can see while writing them. Only one of them actually fixes the underlying issue. How do you tell which — without reading either patch's code?
Click through the three patches. indexOf (Patch A) and the hardcoded shortcut (Patch C) both pass
exactly 3 of the 5 hidden tests — the scoreboard shows the identical bar for both — but look at which
three: the two patches don't agree with each other, because they're wrong for entirely different
reasons.
SWE-bench and its relatives score a patch against a hidden test suite — a fixed set of unit tests the model never sees while writing the patch. A patch's score is just the fraction of those tests it passes, and it only counts as resolving the issue if that fraction is exactly 1 — no partial credit.
- — a candidate patch: a function that's actually executed, not graded by inspection.
- — the fixed hidden test suite (5 cases here); the model never sees these while writing .
- — 1 if the patch's output matches the expected value on that test, else 0.
- resolves() — the actual SWE-bench bar: every single test must pass, not "most."
- The bug: last_index should find the LAST match, not the first
last_index([1,2,3,2,1], 2)should return3(the last position of2), not1. - Patch A (indexOf) passes the easy cases, fails the ones that matter
[1,2,3,2,1]→indexOfgives1, expected3: fail.[5,5,5]→indexOfgives0, expected2: fail.
The other three tests pass regardless, because there's no duplicate to disagree on — first and last position coincide.
- Patch B (lastIndexOf) is the real fix
All 5 cases match exactly, because
lastIndexOfis what "last occurrence" actually means. - Patch C ties Patch A's score for a completely different reason
Patch C hardcodes the answer for the one test that was visible during development and falls back to
-1for everything else. It matches Patch A's 3-of-5 score without sharing a single line of real logic — and it fails a different pair of tests.
Switch to Patch B and the readout flips to "resolves the issue" — the only one of the three that does. Every hidden test has to agree; there's no reward here for getting most of them right.
Score Patch C by hand against all 5 hidden tests:
- [1,2,3,2,1], target 2 → expected 3
arr.length === 5 && target === 2is true, so Patch C returns3. Matches. Pass. - [5,5,5], target 5 → expected 2
Length is 3, not 5, so the condition is false and it falls to
-1. Expected2. Fail. - [1,2,3], target 4 → expected -1
Length is 3, not 5, so the condition is false and it falls to
-1. Matches. Pass. - [], target 1 → expected -1
Condition is false (length is 0, not 5), returns
-1. Matches. Pass. - [7], target 7 → expected 0
Condition is false (length is 1, not 5), returns
-1. Expected0. Fail.
3 of 5 pass — passRate = 0.6, the identical number Patch A scored, but on rows 1, 3, 4 instead of A's rows 3, 4, 5. Neither patch resolves the issue.
Select the one patch, among the three, that resolves the issue — passes every test in the hidden suite.
A pass rate alone can't tell a patch that's almost right from one that's right by coincidence in a completely different spot — Patch A and Patch C proved that by tying at 0.6 while failing different tests. SWE-bench sidesteps the ambiguity by refusing partial credit: the hidden suite either passes in full or the issue isn't resolved. The next chapter asks what happens once running that hidden suite is only safe to do after a human has signed off on the action in the first place.