SWE-Protégé: Small Language Models for Software Engineering Through Learned Expert Collaboration

Patrick Tser Jern Kon, Archana Pradeep, Ang Chen, Alexander P. Ellis, Warren Hunt, Zijian Wang, John Yang, Samuel ThompsonNeurIPS 2026

TL;DR

Small language models (SLMs) are fast and cheap, but when asked to solve complex, multi-step software engineering tasks, they tend to get stuck in repetitive loops. SWE-Protégé solves this by training a 7B-parameter model to act like a savvy junior developer: it handles the routine legwork on its own, recognizes when it’s stuck, and selectively pings a frontier "expert" model for high-level guidance. The result is a hybrid system that boosts SLM bug-fixing performance by over 25% while slashing frontier API costs by more than 8×.

What Problem Does This Paper Address?

Autonomous software engineering—navigating a massive codebase, reproducing a bug, editing files, and running tests—is a marathon, not a sprint. Currently, massive frontier models (like Claude Sonnet or Opus) dominate benchmarks like SWE-bench, while small language models ($\le$10B parameters) struggle, resolving only around 10–18% of tasks.

Left to their own devices over dozens of turns, SLMs suffer from "degenerative stalling"—like a tired engineer at 2 a.m. running the exact same grep command twenty times hoping a different file will magically appear. Simply training SLMs on more synthetic examples of successful trajectories doesn't fix this; in fact, scaling up standard imitation learning can actually cause their performance to regress. Running frontier models for every step works, of course, but quickly runs into steep API costs and rate limits. The authors ask: instead of forcing an SLM to work solo, can we teach it how to pair-program with an expert?

Methods

SWE-Protégé takes an existing coding scaffold (SWE-agent) and adds a single new tool to the SLM’s repertoire (ask_expert). To keep expert consultations cheap, the expert isn't fed the entire codebase history—just the SLM's specific question and the last 5 interaction turns.

The two-phase SWE-Protégé training pipeline and resulting pair-programming behavior.

Teaching the SLM (Qwen2.5-Coder-7B) to use this tool effectively requires a two-phase post-training pipeline:

  1. Phase I: Supervised Fine-Tuning (SFT). Small models don't naturally know how to use new tools just from prompting. The authors generate synthetic, expert-augmented trajectories using a strong model (Claude Sonnet 3.7) playing both roles, and fine-tune the 7B model on ~4.8k successful runs. This teaches the mechanics of asking for help, though the model still frequently loops or ignores the advice it receives.
  2. Phase II: Agentic Reinforcement Learning (GRPO). Using Group Relative Policy Optimization on the SLM's own rollouts, the authors shape its behavior with a clever two-stage reward curriculum. Alongside standard rewards for passing unit tests, they repurpose the expert as a hidden, in-trajectory judge to evaluate collaboration quality. First, the reward heavily penalizes repetitive command loops, forcing the stalled SLM to ask the expert instead of spinning its wheels. Second, it penalizes lazy questions and failing to follow through on the expert's advice, turning one-off hints into genuine multi-turn pair programming.

Datasets

  • Training: Phase I SFT uses ~4.8k resolved task trajectories sampled from the SWE-smith dataset. Phase II RL uses a small, 100-task subset of SWE-Gym.
  • Evaluation: Primary evaluation uses SWE-bench Verified (500 human-vetted real-world GitHub issues). To check for data contamination—since frontier experts might have memorized older GitHub issues—they also test on a held-out 400-task subset of SWE-smith released after the expert models' training cutoffs. Finally, MATH, GSM8K, and MMLU verify that general reasoning isn't degraded.

Key Insights and Ideas

  • Expert collaboration unlocks data scaling for SLMs: While baseline 7B models plateau and even regress as you feed them more standard SFT trajectories, SWE-Protégé scales monotonically—because it no longer has to memorize its way out of every complex corner.
  • RL as "trajectory hygiene" rather than raw capability: Phase II RL only requires 100 tasks and 160 training steps. It adds a modest bump to accuracy (+3.6% on average), but its real magic is behavioral: it eliminates repetitive command loops and slashes total token usage by ~40%.
  • Autonomous escalation beats rigid rules: Forcing expert calls on a fixed schedule or at random performs poorly (19.6% and 24.2% accuracy). Teaching the SLM to autonomously recognize its own confusion and formulate a targeted question is what drives the gains.

Key Results

On SWE-bench Verified (single attempt, Pass@1):

  • State-of-the-art SLM hybrid performance: SWE-Protégé-7B achieves 42.4% accuracy when paired with Claude Opus 4.1 (up +25.4% over the 17.0% SWE-agent-LM-7B baseline, and even edging out a standalone 32B open-weight model at 40.2%). With Sonnet 4.5, it reaches 41.0%.
  • Sparse, cheap expert usage: The protégé does ~88–89% of the token generation itself, calling the expert roughly 4 times per task. With Sonnet 4.5, the median expert API cost is just **$0.15 per task**—**8.2× cheaper** than letting Sonnet 4.5 solve the task directly ($1.24).
Figure 4: SWE-Protégé substantially reduces per- task expert API cost relative to direct expert execu- tion (the expert solves the entire task). Details in §4.1.
  • Goodbye, infinite loops: Severe stalling (repeating action patterns for >10 steps) plummets from 31.0% of trajectories after SFT to just 0.8% after RL, dramatically reducing tasks that abort due to hitting step or cost limits.
Figure 5: Phase II RL (P2) sharply reduces cost/step limit aborts relative to post-SFT (P1) and SWE-smith baselines.

Limitations and Future Work

SWE-Protégé is fundamentally a hybrid system—turn off access to the frontier expert, and the 7B model drops right back to baseline 7B performance. Additionally, the loop-detection penalty relies on normalizing bash-style commands, which would need rethinking for other agent environments like GUI navigation. Finally, the authors note diminishing returns when scaling the protégé up to 32B (+1.5% gain on the held-out set) while keeping a fixed, black-box expert. Future work points toward co-adapting and post-training the expert model itself, as well as exploring richer collaboration mechanics—like letting the expert interrupt the junior coder before they wander down the wrong directory.

Summary updated

Abstract

Small language models (SLMs) offer compelling advantages in cost, latency, and adaptability, but have lagged behind larger models on long-horizon software engineering tasks such as SWE-bench, where they suffer from pervasive action looping and low resolution rates. We introduce SWE-Protégé, a post-training framework that reframes software repair as an expert–protégé collaboration problem. In SWE-Protégé, an SLM remains the primary decision-maker while learning to selectively seek guidance from a strong expert model, recognize stalled states, and follow through on expert feedback. Our approach combines supervised fine-tuning on expert-augmented trajectories with agentic reinforcement learning that explicitly discourages degenerative looping and unproductive expert collaboration. We lightly post-train Qwen2.5-Coder-7B-Instruct to achieve 42.4% Pass@1 on SWE-bench Verified with SWE-agent and Claude Opus 4.1 as the expert, a +25.4% improvement over the prior SLM state of the art, while using expert assistance sparsely (≈4 calls per task and 11% of total tokens). With Claude Sonnet 4.5 as the expert, it reaches 41.0% at a median expert API cost of USD 0.15 per task, 8.2× lower than running the expert alone.
BibTeX
@inproceedings{kon2026swe,
  author = {Patrick Tser Jern Kon and Archana Pradeep and Ang Chen and Alexander P. Ellis and Warren Hunt and Zijian Wang and John Yang and Samuel Thompson},
  title = {{SWE-Protégé: Small Language Models for Software Engineering Through Learned Expert Collaboration}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=1gT9qIbj9f},
}
Figure