How to Build a Reproducible Benchmark for LLM Coding Agents

    Single-turn code generation tests cannot capture how coding agents actually work in real projects. This article explains how to design a reproducible benchmark that evaluates agents on full development trajectories, covering environment setup, metric definitions, trace recording, orchestration fault tolerance, and practical steps for enterprise adoption.

    Single-turn code generation benchmarks only measure whether a model can write a correct function in one shot. They fail to reflect what matters in real projects: reading existing code, calling tools, and fixing approaches based on error messages. This article explains how to build a benchmark that mirrors a real development environment, with metric definitions, prerequisites, and an implementation checklist so teams can reproduce results and make meaningful comparisons.

    1. Why Move to Real-Trajectory Evaluation

    A real agent workflow includes environment perception, task decomposition, tool calls, result feedback, and iterative correction. Each step changes the input of the next. Single-turn Q&A datasets cannot cover this continuous evolution, so evaluation inputs must include full development context, such as project structure, dependency relationships, and commit history. Models should be asked to extend features or fix defects in an existing codebase, working the way a real developer would.

    2. Prerequisites Before Running Tests

    Before evaluation begins, fix the following items; otherwise results cannot be reproduced.

    1. Sandbox environment: Each task runs in an isolated container with project dependencies pre-installed, and language runtime and dependency versions locked.
    2. Permission boundaries: Inside the sandbox, agents may read and write the project directory and execute test commands, but must not access host machine paths. If external network access is truly needed, use a domain allowlist.
    3. Task definition: Each task includes an initial codebase snapshot, a requirement description, acceptance tests, and a timeout. Acceptance tests run in a separate process after the task ends — never as model self-assessment.
    4. Model configuration: Record the model name, version, temperature, maximum output length, and a hash of the system prompt.

    3. Metric Definitions and Calculation Rules

    Metrics must specify the numerator, denominator, and statistical boundaries; otherwise numbers from different teams cannot be compared.

    Task completion rate: the number of tasks passing all acceptance tests divided by the total number of tasks. Run each task at least 3 times, compute the pass ratio per task, then average across all tasks.

    Trajectory efficiency covers three items: number of interaction turns, number of tool calls, and total token count. Token statistics should be based on the input/output usage returned by the model API, excluding sandbox command execution time. Turn counting starts at task start and ends when the model submits its result or the timeout triggers.

    Error recovery capability: among trajectories that encountered at least one execution failure (compile error, test failure, or tool error), the proportion that eventually passed acceptance within a set number of turns (e.g., 10). The denominator includes only trajectories that had failures, so tasks passed on the first try are not counted.

    These thresholds can be adjusted to your team’s scenario, but any adjustment must be noted in the report.

    4. Trace Recording Structure

    Every step should record enough information for later failure analysis. The following pseudocode extends basic fields with context length, tool status, and error type.

    1. class AgentTrace:
    2. def __init__(self, task_id, model_version):
    3. self.task_id = task_id
    4. self.model_version = model_version
    5. self.steps = []
    6. def add_step(self, thought, action, observation,
    7. context_length, tool_status, error_type=None):
    8. self.steps.append({
    9. "thought": thought,
    10. "action": action,
    11. "observation": observation,
    12. "context_length": context_length,
    13. "tool_status": tool_status, # ok / timeout / schema_error / exec_error
    14. "error_type": error_type,
    15. })

    When a tool parameter fails to parse, record it as schema_error and return the error message to the model in the next step. Retry and interception logic should live in the orchestration layer and be executed by code, not left to the model to fix its own output format.

    5. How to Interpret Model Performance

    Teams often want a direct “which model is best” verdict. A more reliable approach is to examine metric distributions first, then review failure samples.

    In comparable tests, three patterns may appear. First, some models produce reasonable task decomposition plans but deviate from them during execution. Second, as turns increase and context approaches the model’s limit, early constraints are more likely to be ignored. Third, when facing complex logic, tool call parameters may violate the interface specification.

    These are hypotheses to verify, not conclusions. Every comparison should state the model version, task set, sample size, and metric definitions, and report counts by failure type rather than a single overall score. If the completion rate gap between two models is smaller than the statistical fluctuation, treat it as no significant difference.

    6. Infrastructure Factors That Affect Results

    Benchmark results depend on the underlying infrastructure, especially resource contention and timeout settings. Three components deserve attention:

    Container isolation: Each task runs in its own container with CPU and memory limits and an execution timeout. Resource limits must be fixed; otherwise the same task may yield different results under different loads.

    Asynchronous storage: Full trajectories can be large. Write them to object storage via a message queue to avoid blocking agent execution. Retry on write failure and log the affected task IDs.

    Observability: Record model inference latency, tool execution time, and queue time. These data reveal whether time is spent mainly on model inference or sandbox execution.

    The purpose of these components is to make results explainable. Whether they improve performance must be measured by running the same task set before and after the changes — never inferred from architecture design alone.

    7. Three Practices for Enterprise Adoption

    1. Build a domain-specific task set

    Steps: collect defect fixes and feature requests merged by your team in the past six months; strip sensitive information and internal addresses; write automatically executable acceptance tests for each task; stratify tasks by difficulty (single-file changes, cross-module changes, multi-round debugging); freeze the version — afterwards only add tasks, never modify existing ones.

    Acceptance criteria: the task set covers the team’s main tech stack, each core module has at least 20 tasks, and spot checks confirm acceptance tests produce no false verdicts.

    2. Design fault tolerance in the orchestration layer

    Validate tool parameters against a JSON Schema first. On validation failure, return the error to the model for a retry, up to 2 times. If the same action fails 3 times in a row, abort the task and escalate to a human. Log all interceptions and retries in the trace.

    Acceptance criteria: the count and causes of tool call interruptions can be extracted from logs, and before/after data can be compared when rules change.

    3. Manage the context window

    Keep task constraints and the most recent interactions. Summarize older tool outputs before putting them back into context. Fixed information such as project conventions stays in a fixed position in the prompt.

    Acceptance criteria: on a long-trajectory subset, the trimming strategy’s completion rate is no lower than the untrimmed baseline, and token consumption decreases.

    8. Boundaries of Sub-agent Architectures

    Having a primary agent decompose tasks and delegate to sub-agents can handle larger requirements