Post-Training Gains and Evaluation Bias in Software Engineering Agents

    This article explains why large gains on a specific software engineering benchmark should not be read as a proportional increase in general model capability. It breaks down post-training mechanisms such as cost-aware rewards, length-weighted baselines, rollout-length stabilization, and long-horizon data, then analyzes benchmark-training overlap, execution-framework differences, task-distribution mismatch, and insufficient task-level statistics. It concludes with a layered evaluation and cross-environment reproduction approach for judging software engineering agent results.

    The conclusion first: a large gap on a specific software engineering leaderboard usually should not be interpreted as a model having doubled its general capability. More often, post-training converts a base model’s general code-understanding ability into specialized strategies for a particular task class, toolchain, or scoring standard. If the benchmark, execution framework, and training environment are also highly similar, the gap can be further amplified. To judge whether such results are credible, one needs to examine the training method, evaluation design, and cross-environment reproduction results together.

    1. Why Post-Training Can Significantly Change Software Engineering Agent Performance

    Software engineering agents differ from ordinary code-generation models. They need to read repositories, locate issues, modify files, run tests, handle failures, recover context, and finally submit changes that maintainers can accept, all across multiple interaction rounds. Even if a base model has strong code knowledge, it does not necessarily have a stable long-horizon task strategy. The value of reinforcement-learning post-training is to shift the model from “can write code” to “can complete the engineering loop under a task budget.”

    This process contains at least four types of gains. First, task data shifts from isolated code snippets to real repository-level issues, so the model learns cross-file dependencies and implicit constraints. Second, the reward function expands from “whether tests pass” to “whether the change is minimal, whether it introduces regressions, whether it remains compatible with existing inputs, and whether tool-call costs are reasonable.” Third, long-horizon trajectory training improves the model’s ability to recover after failure. Fourth, training-stability management reduces policy oscillation over long trajectories. If these parts are done well, it is reasonable for a post-trained version to clearly outperform the base model on a specific task distribution.

    However, “a significant lead on a specific leaderboard” and “a multiplicative lead in general software engineering capability” are two different claims. The former can be explained by task distribution, scoring standards, execution framework, and training homology. The latter requires blind-test evidence across leaderboards, toolchains, and repository types.

    2. Key Technical Components

    2.1 Cost-Penalized Reward Function

    Traditional rewards tend to look only at test pass rates, which can lead the policy to make many attempts, over-edit, or repeatedly call tools. A cost-penalized reward function includes invalid edits, extra file changes, tool-call counts, latency, and regression risk as penalty terms, so the model balances “passing tests” with “engineering acceptability.” The core is not simply to lower cost, but to align the reward with maintainer acceptance criteria.

    Pseudo-code:

    1. function shaped_reward(result, cost, baseline):
    2. task_score = result.test_pass_rate
    3. regression_penalty = -0.5 * result.regression_count
    4. invalid_edit_penalty = -0.2 * result.invalid_edit_count
    5. cost_penalty = -0.01 * cost.token_cost - 0.02 * cost.tool_calls
    6. length_penalty = -0.001 * max(0, result.trajectory_length - result.expected_budget)
    7. return task_score + regression_penalty + invalid_edit_penalty
    8. + cost_penalty + length_penalty

    This type of reward can suppress short-sighted “pass-rate gaming,” but it also creates new problems: if penalties are too strong, exploration willingness decreases, and the model becomes afraid to make necessary changes. In engineering practice, costs usually need to be normalized by task difficulty, and different task types need different budgets rather than a single global fixed weight.

    2.2 Length-Weighted Reward Baseline

    Reward variance is usually higher for long-trajectory tasks. The same policy may be stable on short tasks but fluctuate heavily on long tasks because of a single tool-call failure or context loss. If a global mean reward is used directly as the baseline, the advantage estimates for long trajectories can be overwhelmed by short tasks. The idea of a length-weighted reward baseline is to bucket by trajectory length, task difficulty, or tool-call count, compute the baseline within each bucket, and then normalize advantages.

    Pseudo-code:

    1. function length_weighted_advantage(rewards, lengths, buckets):
    2. advantages = []
    3. for each bucket in buckets:
    4. group = rewards where length in bucket
    5. baseline = mean(group)
    6. variance = var(group)
    7. for r, length in group:
    8. weight = 1 / sqrt(length + 1)
    9. adv = (r - baseline) / sqrt(variance + eps) * weight
    10. advantages.append(adv)
    11. return advantages

    This approach cannot create capability out of nothing, but it can reduce training noise and help the policy learn effective long-horizon behaviors more stably. It needs to be combined with reward clipping, gradient clipping, and early stopping; otherwise, it may amplify outlier samples.

    2.3 Rollout Length Oscillation Control

    A common problem in reinforcement-learning training is trajectory-length oscillation. Sometimes the model over-extends reasoning and tool calls, trying to trade more steps for a higher pass rate; sometimes it is compressed too aggressively by the length penalty, so the task remains unfinished. The root causes are usually coupling between reward and length, overly hard truncation thresholds, and high variance in long-trajectory advantage estimates.

    Governance ideas include dynamic truncation by task budget instead of a fixed maximum length; normalizing advantages separately after bucketing by length; decoupling task-completion reward from length penalty; early termination of trajectories that repeatedly exceed budget; short-to-long curriculum learning; KL constraints and gradient clipping to limit abrupt policy changes; and monitoring the length distribution during training rather than only the mean reward. Only when the length distribution is stable are score improvements more likely to come from policy improvement rather than reward loopholes.

    2.4 Long-Horizon Task Data and Training Stability

    The long-horizon nature of software engineering tasks is reflected in state tracking and error recovery. High-quality training data should cover multi-file edits, rollback after test failures, backward compatibility with old interfaces, handling edge-case inputs, and self-checking against merge-request standards. If training data emphasizes only “final tests pass,” the model may learn local patching. If the data includes maintainer acceptance logic, the model is more likely to learn engineering constraints.

    For training stability, attention should be paid to reward scale, advantage estimation, sampling temperature, and tool-call failure rates. A post-trained version that performs strongly in an in-house execution framework may benefit because training and inference use the same tool interface, the same context-management strategy, and the same retry logic. This is not fake, but it means performance may drop when reproduced across frameworks.

    3. Main Sources of Benchmark Gaps

    First, benchmark-training overlap. If the benchmark publisher and the post-training team are closely related, scoring standards, prompt style, and acceptance rules may be indirectly absorbed by the training process. This is especially true when prompts deliberately leave gaps or set veto items based on maintainer standards: passing ordinary unit tests is not the same as passing acceptance. Failure to fix issues on the same path or failure to remain compatible with existing repository input types can lead directly to a zero score. Without targeted training, many models will clearly lose points on such benchmarks; conversely, teams familiar with the scoring standards are more likely to obtain high scores.

    Second, execution-framework differences. The same base model can perform noticeably differently under different command-line execution frameworks, context-compression strategies, and retry mechanisms. When an in-house framework matches the training environment, tool-call formats, error recovery, and output parsing all align more closely, so the model naturally has an advantage. Therefore, when comparing different agents, the execution framework should be fixed, or at least cross-validated across multiple frameworks.

    Third, task-distribution and general-capability mismatch. A base model may be trained across many domains and have strong general capability, but software-maintenance tasks place more emphasis on repository-level constraints, regression control, and long-horizon stability. If a post-trained version is specifically optimized for these tasks, it is not surprising for it to outperform the base model on a specific benchmark. But this does not mean it has a multiplicative lead on all programming tasks.

    Fourth, insufficient evaluation statistics and task-level analysis. Looking only at the total score easily hides differences in task types. Confidence intervals, task-level failure modes, cost metrics, and length distributions should be reported. If a version leads substantially only on a few long-horizon tasks while tying on simple tasks, the result cannot be extrapolated to an overall doubling of capability.

    4. Engineering Practice Recommendations

    Build a layered evaluation matrix: evaluate basic code generation, repository-level repair, regression control, long-horizon tool use, and cross-framework reproduction separately. Use a fixed execution framework for longitudinal comparison, then use multiple neutral frameworks for horizontal validation. For benchmark-overlap risk, use blind tasks, hidden acceptance criteria, and leakage-safe data. Training and evaluation pipelines can be deployed in cloud environments with general-purpose compute, object storage, logging, and monitoring capabilities—for example, general-purpose product categories from Baidu AI Cloud—to track the reward, length, tool calls, and failure reasons of each trajectory.

    At the same time, cost, latency, and stability should be included in agent evaluation. A version that scores highly on a specific benchmark is not necessarily suitable for direct production use if its tool-call cost is too high, long-task oscillation is obvious, or performance drops severely across frameworks. Truly reproducible conclusions should come from cross-validation across multiple leaderboards, multiple frameworks, and multiple repository types, rather than from a multiplicative gap on a single homologous benchmark.