Evaluating LLM Code Generation: From Pass@K to Sandbox Regression Testing

Early benchmarks for code-generating models (such as HumanEval and MBPP) measured isolated function synthesis against rudimentary unit tests. In real-world enterprise repositories, however, synthetic Pass@1 metrics provide almost zero correlation with whether an autonomous agent can successfully resolve production tickets.

Modern evaluation suites have shifted from single-function Pass@K to Hermetic Repository-Level Regression Testing.

MERMAID
flowchart LR
    Bug["GitHub Issue / Production Alert"] --> Agent["Autonomous Coding Agent"]
    Agent --> Patch["Synthesized Git Patch"]
    Patch --> Sandbox["Isolated Docker Micro-VM"]
    Sandbox --> Build["npm/cargo/mvn Build"]
    Sandbox --> ExistingTests["Pre-existing Test Suite (Regression Guard)"]
    Sandbox --> Reproducer["Fail-to-Pass Repro Test"]
    ExistingTests --> Gate{All Tests Pass?}
    Reproducer --> Gate
    Gate -->|Yes| Accepted["Merge Candidate Approved"]
    Gate -->|No| Rejected["Diagnostic Rollback Triggered"]
✦

1. The Flaws of Static Pass@K

The unbiased Pass@k metric:

$$\text{Pass}@k = \mathbb{E}\left[1 - \frac{\binom{n - c}{k}}{\binom{n}{k}}\right]$$

assumes independent sample evaluations without context or compiler interaction. This creates severe distortion:

✦

2. The SWE-Bench Evaluation Paradigm

Enterprise evaluation harnesses (such as SWE-Bench and custom repository sandboxes) evaluate complete Git diffs against full project workspaces:

Evaluation Dimension HumanEval / MBPP Full Repository Sandbox
Workspace Scope Single isolated function 50,000+ line repository
Execution Environment In-process Python eval Ephemeral Linux container
Verification Gate Assert statements only Build + Lint + Test Suite + E2E
Fail-to-Pass Verification None Must flip failing test to passing
Pass-to-Pass Verification None Must NOT break existing tests
✦

3. Best Practices for Production Test Harnesses