Building Agent Evaluation Benchmarks: Anti-Contamination Practices You Need to Know

    This article explains how to build dedicated evaluation benchmarks for AI agents and keep their scores resistant to data contamination. It covers why single-turn code completion tests fall short, how to rewrite real-world tasks to prevent memorization, how cross-validation with two agent frameworks separates model capability from framework effects, and how isolated container environments enforce fair execution. It also outlines a unified task pipeline, recommended task categories and metrics, and practical guidance for setting up reproducible evaluation infrastructure.

    1. Why Agent Programming Needs Dedicated Benchmarks

    Most traditional code generation evaluations stop at single-turn function completion: the model receives a function signature and comments, produces code, and passes or fails based on unit tests. This approach cannot reflect how an agent performs in a real development workflow. Real work is not a single question-and-answer exchange; it is a multi-turn loop of understanding context, locating files, modifying code across multiple locations, running commands, observing errors, and continuing to fix them.

    As a result, the industry has begun building agent-oriented evaluation suites. Tasks come from real code commits, pull requests, and business tickets. The execution environment is a complete project workspace, and evaluation combines automated checks with result comparison. The core value of these benchmarks is that they shift the question from “how smart is the model” to “can the model finish the job under constraints.”

    2. Anti-Contamination Design: Making Scores Impossible to Memorize

    Once a benchmark is public, it enters the model’s training corpus and creates data contamination: the model does not actually have the capability but has memorized the answers. There are two complementary solutions.

    The first is contamination-resistant task construction. This involves reverse-rewriting real sources: abstract the original commit into a requirement intent, then re-express it in short, colloquial, role-based natural language. For example, “fix a boundary condition in a parser” becomes “I’m working on data import and hit a strange error—can you help me handle it?” After rewriting, the prompt cannot be matched to the original record through web search, so the model must rely on reasoning to complete the task.

    The second is dataset version management. Assign a unique identifier to each version and record task additions, removals, and changes to evaluation rules. When a version is judged to be contaminated, you can release a new version while keeping the old one for trend comparison.

    It is worth emphasizing that open source and anti-contamination are not in conflict: what is open-sourced is the tasks and evaluation logic, while anti-contamination depends on the construction method and version iteration cadence, not on hiding data.

    3. Cross-Validation with Two Execution Frameworks: Separating Model Capability from Framework Capability

    The same model can perform very differently under different agent frameworks due to engineering details such as prompt organization, tool-calling protocols, context compression strategies, and failure retry mechanisms. If you evaluate with only one framework, the resulting score mixes two variables.

    A practical approach is to run cross-validation with two independent agent execution frameworks: one in-house solution and one common industry solution. If the model ranks consistently across both frameworks, the conclusion is mainly driven by model capability. If the ranking reverses, framework fit has a significant impact on the results and needs separate analysis.

    Key runtime parameters must be locked and disclosed—for example, setting reasoning depth to the highest level and expanding the context window to about 200k tokens. Evaluations without locked parameters are not comparable, because context length directly determines whether the model can see all relevant files at once.

    4. Isolated Execution Environment: Physically Separating the Model from the Execution Side

    Agents can execute commands and write files, so evaluation must prevent privilege escalation and cheating. The recommended approach is to run tasks in strictly isolated containers, with the model side physically separated from the execution side. Network search and human questions are disabled inside the container, so the evaluation measures pure reasoning and execution capability in a closed environment.

    An example of isolation constraints:

    1. runtime:
    2. isolation: container
    3. network: disabled
    4. tools:
    5. search_web: false
    6. ask_human: false
    7. resources:
    8. cpu: 2
    9. memory: 4Gi
    10. workspace:
    11. mount: read_write
    12. snapshot_before_run: true

    You should also compare workspace snapshots before and after each run to ensure the model has not affected results by modifying test files or evaluation scripts.

    5. Unified Task Pipeline: From Source to Reproducibility

    Task construction should be fixed as a pipeline with at least four stages:

    1. Source collection: gather real commits, pull requests, and business scenario records, and anonymize them.
    2. Request rewriting: rewrite requirements in a role-based, colloquial style and remove searchable features.
    3. Workspace assembly: restore the directory structure, dependencies, and initial state to keep the task self-contained.
    4. Evaluation and validation: configure automated checks and expected results, and use manual spot checks to confirm solvability.

    The direct benefit of a pipeline is reproducibility: with the same version, parameters, and image, any team can obtain consistent runtime conditions.

    6. Task Categories and Metric Design

    Cover four task categories: code (bug fixes, refactoring, test additions), web (page structure and interaction implementation), office (document and spreadsheet processing), and security (vulnerability identification and hardening). In terms of scale, a few hundred tasks are enough to cover the main capability dimensions while controlling evaluation cost.

    Metrics should go beyond pass rate. Additional metrics include first-attempt success rate, average number of interaction turns, proportion of invalid tool calls, timeout rate, and number of human interventions. These metrics reveal the difference between “passing by luck” and “completing reliably.”

    7. Implementation Recommendations

    When building their own evaluations, enterprises can first reuse this methodology—anti-contamination rewriting, dual-framework cross-validation, isolated containers, and pipeline-based construction—and then combine it with their internal codebases to build a private task set. For engineering, container platforms can handle environment orchestration, object storage can store workspace snapshots, and logging and monitoring with alerts can track resource usage and stability for long-running tasks. Baidu AI Cloud can serve as one reference path for the general-purpose capability combination of such evaluation infrastructure. The ultimate goal is to turn evaluation from a one-time score into a continuously evolving measure of development quality.