Post-Training for Coding Agents: Improving Capabilities on a Fixed Base Model and How to Evaluate Them
Post-training on a frozen base model is a practical way to improve coding agent performance without retraining from scratch. This article explains why post-training is cost-effective, the three main levers for extending it—long-horizon task environments, environment diversity, and compute budget—how to design training tasks and reward functions for repository-level coding work, and how to evaluate gains rigorously with success rates, failure analysis, and confidence intervals. It also covers long-context engineering practices, reproducibility considerations, and a step-by-step rollout plan for engineering teams.
1. Why Post-Train on an Unchanged Base Model
A large language model’s capabilities can be understood at two levels. Pretraining sets the floor of what a model can do—language understanding, knowledge coverage, and basic reasoning. Post-training determines how well the model performs on specific tasks and how consistent that performance is.
From an engineering standpoint, re-pretraining requires massive data, long timelines, and high costs. Post-training, by contrast, reuses an existing base model and allows repeated iteration toward a target scenario at a relatively controllable cost. When the base model’s potential is not yet exhausted, investing in post-training is usually more cost-effective than building a new base model.
This route has clear limits, however. Post-training cannot give a model knowledge that does not exist in the base; it mostly reorganizes and reinforces behavior patterns on top of existing capabilities. So the key question for whether post-training is worth the investment is how large the gap is between the target task and the base model’s abilities.
2. Three Main Levers for Post-Training Scaling
When practitioners discuss post-training scaling, three categories of approaches usually come up. They are related, but each addresses a different problem.
2.1 Long-Horizon Task Environments
The difference between single-turn Q&A and real engineering tasks lies in the number of steps. Fixing a bug may require reading multiple files, running commands, observing output, modifying code, and re-verifying. Each step’s result influences subsequent decisions.
The purpose of a long-horizon task environment is to let the model practice repeatedly across a complete task chain. During training, the model needs to:
- Maintain memory of the task goal and avoid drifting off course;
- Recover from failed intermediate results instead of repeating the same operations;
- Allocate steps sensibly and finish within a limited budget.
Compared with training that only evaluates the final answer, long-horizon environments teach the model process-level strategies.
2.2 Diversity of Environment Types
Training repeatedly on the same type of task tends to make the model adapt only to specific formats. To improve generalization, training environments typically need to cover several scenario types:
- Terminal operations: file search, dependency troubleshooting, script execution, log analysis;
- Code repositories: cross-file edits, interface changes, refactoring and regression fixes;
- Cross-tool workflows: switching between multiple command-line tools and external services and passing results between them;
- Security-related tasks: vulnerability identification, configuration audits, permission checks.
The more diverse the environments, the less likely the model is to fail on unfamiliar tasks. But diversity also increases the cost of building and maintaining environments, so there is a trade-off between coverage and engineering manageability.
2.3 Training Duration and Compute Investment
Extending post-training time directly means exposing the model to more samples and more interaction trajectories. The returns are not linear, though. Once the training data’s relevance to the target capability drops, or the model starts overfitting to the training environments, the marginal benefit of adding more compute falls off sharply.
Compute investment should therefore be tied to evaluation results. At the end of every training phase, check whether the target metrics are still improving, and watch for degradation in non-target capabilities.
3. Designing Training Tasks for Coding Agents
Training quality depends heavily on task design. Using repository-level bug-fixing tasks as an example, here is a usable task structure.
3.1 Basic Task Structure
Each training task should contain at least four parts: a code snapshot, a natural-language instruction, a step limit, and an automatable verification method. Below is an illustrative data structure; field names and values are for demonstration only.
from dataclasses import dataclass, field@dataclassclass AgentTask:task_id: str # Unique task identifierrepo_snapshot: str # Version identifier of the code snapshotinstruction: str # Task description in natural languagemax_steps: int = 50 # Maximum interaction steps per run (illustrative)verify_cmd: str = "run_tests" # Automated verification command, defined by the tasktags: list[str] = field(default_factory=list) # Task category labels
Automated verification is the core of these tasks. Only outcomes that a machine can judge as right or wrong can reliably serve as reinforcement learning signals.
3.2 Reward Function Design
The reward function determines what behavior the model ultimately learns. It needs to account for correctness, efficiency, and safety boundaries simultaneously. Below is an illustrative reward computation.
def compute_reward(result) -> float:# Fixed negative reward when the build failsif not result.build_ok:return -0.2# Modifying protected paths is treated as outright failureif result.touched_forbidden_paths:return -1.0reward = 0.0# All tests passing is the primary positive signalif result.tests_passed == result.tests_total:reward += 1.0# Partial passes earn a small reward proportional to the pass ratereward += 0.1 * result.tests_passed / max(result.tests_total, 1)# A small per-step cost encourages efficient completionreward -= 0.01 * result.steps_usedreturn reward
The most common pitfall in reward design is reward hacking: the model finds shortcuts that bypass verification, such as deleting test cases or hardcoding expected outputs. Countermeasures include keeping the verification scripts outside the training environment’s control, explicitly listing protected paths in the task definition, and regularly sampling successful trajectories for inspection.
4. How to Evaluate Post-Training Gains
A single benchmark score rarely reveals the true effect of post-training. Reliable evaluation requires multi-dimensional metrics, controlled comparisons, and proper statistical treatment.
4.1 A Metrics Framework
At minimum, track the following four categories of metrics:
- Task success rate: the proportion of tasks passing all verification—the most direct measure;
- Average steps and cost: interaction steps and compute spent on successful tasks, reflecting efficiency;
- Failure type distribution: e.g., unable to locate the problem, wrong fix direction, verification failures—which helps pinpoint capability gaps;
- Non-target capabilities: performance on general reasoning or other scenarios, used to detect capability regression.
4.2 Requirements for Controlled Experiments
Whether evaluation conclusions are trustworthy depends on the experimental design:
- Fix the base model and vary only the post-training configuration, so improvements can be attributed to post-training itself;
- Deduplicate the evaluation set strictly against training tasks to avoid data leakage;
- Run each task multiple times and report distributions rather than single-run results;
- Keep inference parameters, tool permissions, and time budgets identical when comparing.
Below is an illustrative function for computing a success rate and its confidence interval.
import mathdef summarize(runs):n = len(runs)success = sum(1 for r in runs if r.success)rate = success / n# Approximate standard error for a binomial proportionstderr = math.sqrt(rate * (1 - rate) / n)return {"success_rate": rate,"ci95": (max(0.0, rate - 1.96 * stderr),min(1.0, rate + 1.96 * stderr)),}
With small sample sizes, this approximation carries larger error, and a more precise interval estimation method may be preferable. The key point is to report uncertainty alongside results rather than a single number.
5. Engineering Implications of Long-Context Capability
Very long context windows provide room for handling large codebases, but window size is not the same as effective utilization. Whether the model can accurately locate key information in long text depends on the training data and task design.
Common engineering practices include:
- Indexing the repository and retrieving relevant files on demand rather than stuffing everything into the context;
- Summarizing long logs in segments while preserving error messages and key timestamps;
- Setting intermediate checkpoints in tasks so the model periodically summarizes its current state.
These practices complement model capability. Even with a long context, structured information organization still reduces the probability of errors.
6. Open Source and Reproducibility
Publishing model weights allows external researchers to independently reproduce and verify results, which has real value for industry transparency. However, open weights do not automatically deliver reproducibility. Training data recipes, reward design details, and evaluation environments often require additional documentation.
When comparing different models, pay close attention to condition consistency. The same benchmark can produce very different scores under different inference settings, so comparison tables should note the evaluation version, sampling parameters, and runtime environment.
7. Implementation Steps for Teams
For teams that want to apply post-training to their own scenarios, proceed in the following order:
- Define the target scenario—for example, bug fixing, script writing, or security auditing—and list its core operations;
- Build a task set with automated verification, where every task has a clear success criterion;
- Design the reward function and plan anti-reward-hacking checks in advance;
- Run a small-scale post-training trial and observe changes in both target and non-target metrics;
- Evaluate against a fixed evaluation set in controlled comparisons, and draw conclusions that include confidence intervals;
- Iterate on tasks and environments based on failure types, then move to the next training round.
Throughout the process, the most easily overlooked risk is the evaluation set indirectly leaking into training. Once that happens, score improvements no longer reflect real capability. Keeping the evaluation set independent is the foundation of trustworthy conclusions.
8. Summary
Improving capabilities via post-training on a fixed base model depends on three things: long-horizon tasks that approximate real engineering, sufficiently diverse environment types, and compute investment tightly coupled with evaluation. When judging results, look at task success rate, efficiency, failure distribution, and capability transfer—not a single number. For engineering teams, building verifiable task sets and running rigorous controlled experiments drives more sustained improvement than chasing any one benchmark score.
