Priming Base Models for Agentic Post-Training: An Open Midtraining Recipe

Soumye Singhal, Joseph Jennings, Ka Shun Shum, Alexander Bukharin, Khushi Bhardwaj, Zirui Liu, Venkat Srinivasan, Jonathan Li, Yash Jain, Kezhi Kong, Markus Kliegl, Olivier Delalleau, Sanjeev Satheesh, Mostofa PatwaryarXiv 2026

TL;DR

NVIDIA researchers have introduced an open "midtraining" recipe that bridges the gap between standard pretraining and agentic post-training. By training on hundreds of billions of tokens of long-context software engineering data and agentic traces at a 256K context window, they significantly boost the performance and robustness of coding agents on benchmarks like SWE-bench and DeepSWE.

What Problem Does This Paper Address?

Building effective AI agents for software engineering (SE) is challenging because of a "missing middle" in the standard training pipeline.

  • Pretraining typically uses short context windows (4K-8K) and contains almost no agent-environment interactions.
  • Supervised Fine-Tuning (SFT) often relies on synthetic data, and excessively long SFT stages can actually degrade a model's ability to learn from Reinforcement Learning (RL) later on.

Crucial SE data—like entire repositories, complex pull requests (PRs), and long build logs—is often too long for pretraining and too massive for a typical SFT stage. This paper proposes a midtraining stage to ingest this "natural" long-context data and prime the model for agentic tasks before it ever hits the final post-training phase.

Methods

The authors propose a midtraining stage that sits between pretraining and SFT. Key technical choices include:

  • Massive Context: Training at a 256K context window, allowing the model to see entire repositories and long agent trajectories.
  • The "Blend": A mixture of 75% midtraining data, 20% pretraining replay (to prevent forgetting), and 5% long-context data.
  • Loss Masking: In agentic traces, they mask the environment's responses (tool outputs) from the loss function. This forces the model to focus on predicting the agent's actions rather than trying to "world model" noisy logs or file dumps.
  • Evaluation Protocol: Since standard base-model metrics (like perplexity) don't correlate well with agent performance, they use "short SFT" runs (33B tokens) as a fast, reliable proxy to evaluate different midtraining recipes.
Figure 1: The midtraining blend, by share of training tokens. Replay is drawn from the base model’s pretraining data. Token counts and epochs per source are in Table 1.

Datasets

The midtraining blend (summarized in Figure 1 above) consists of several diverse sources:

  • Issue-PR Corpus: 216.9B tokens of merged GitHub PRs, including descriptions, discussions, and code changes.
  • Repositories: 104.1B tokens of public repos, ordered by file dependencies (e.g., imports) rather than alphabetically to help the model learn cross-file structure.
  • Agentic Traces: 39.4B tokens of trajectories from over ten different agent scaffolds (e.g., OpenHands, SWE-agent).
  • Diff Data: 16.0B tokens of commit histories and multi-file edits to teach state-tracking.
  • Build/CI Logs: 6.5B tokens of raw system logs and CI/CD histories.

Evaluation Benchmarks: The models were tested on the SWE-bench suite (Verified, Multilingual, Pro), DeepSWE (long-horizon tasks), Terminal-Bench, and BrowseComp.

Key Insights and Ideas

  • Agentic Traces are Essential: Even though they make up only 10% of the blend, agentic traces provide the majority of the performance gains. Natural SE data alone is not enough to prime a model for tool use.
  • Masking Tool Responses is Better: Training the model to predict what a tool will return (e.g., a file listing or a compiler error) actually lowered performance on SWE-bench by about 10 points. It's better to use that capacity to learn the agent's own actions.
  • Midtraining as Context Extension: Midtraining at 256K naturally extends the model's effective context window, performing nearly as well as dedicated long-context extension stages on benchmarks like RULER.
  • Harness Robustness: Models trained on traces from multiple agent scaffolds become significantly more robust. They perform better regardless of which "harness" (the software environment the agent lives in) is used during evaluation.

Key Results

The midtraining recipe was scaled across two model sizes: Nemotron 3.5 Lightning (30B) and Nemotron 3.5 Super (120B).

  • Lightning (500B tokens): Improved SWE-bench Verified from 60.7 to 64.5 and SWE-bench Multilingual from 55.8 to 62.8 after identical full SFT.
  • Super (280B tokens): Boosted DeepSWE (a particularly difficult benchmark) from 11.7 to 15.7.
  • Efficiency: Midtrained models were more "economical" with their context. For example, on SWE-bench Pro, failures due to filling the 256K context window dropped from 91 instances to just 13 after midtraining.
Midtraining scaling results on Nemotron 3.5 Lightning.

Limitations and Future Work

  • Benchmark Noise: Agentic benchmarks are notoriously noisy; small 1-2 point variations might be due to run-to-run randomness.
  • Model Specificity: The recipe was only tested on the Nemotron family. Its generalizability to other architectures remains to be proven.
  • RL Integration: While the authors show that midtraining gains persist through the start of RL, more extensive research is needed to see how it affects long-term RL training stability.
  • Future Directions: The team plans to scale trace data even further (up to 90B tokens) and expand the recipe to include more diverse agentic capabilities beyond just coding.

Summary updated

BibTeX
@misc{singhal2026priming,
  author = {Soumye Singhal and Joseph Jennings and Ka Shun Shum and Alexander Bukharin and Khushi Bhardwaj and Zirui Liu and Venkat Srinivasan and Jonathan Li and Yash Jain and Kezhi Kong and Markus Kliegl and Olivier Delalleau and Sanjeev Satheesh and Mostofa Patwary},
  title = {{Priming Base Models for Agentic Post-Training: An Open Midtraining Recipe}},
  year = {2026},
  eprint = {2610.22019},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.22019},
}
Figure