SWE-Protégé: Learning to Selectively Collaborate With an Expert Unlocks Small Language Models as Software Engineering Agents

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

Abstract

Small language models (SLMs) offer compelling advantages in cost, latency, and adaptability, but have so far 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 sole 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, 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).

Introduction

While Large Language Models (LLMs) like Claude 3.5 Sonnet have become proficient at solving real-world GitHub issues, Small Language Models (SLMs, typically $\le$ 10B parameters) have historically struggled in this domain. On long-horizon tasks like the SWE-bench benchmark, SLMs frequently fall victim to "degenerative action looping"—the repetitive execution of identical commands (e.g., ls or grep) without meaningful progress. They often lack the high-level intuition required to navigate complex, multi-file codebases effectively.

Scaling data alone has proven insufficient to bridge this gap. SWE-Protégé proposes a different path: rather than attempting to match the raw intelligence of massive models, SLMs should be trained to recognize their own limitations and selectively utilize a "lifeline" to an expert model.

The SWE-Protégé Framework

The core of SWE-Protégé is the reframing of software repair as an expert-protégé collaboration. The SLM (the protégé) acts as the primary agent, handling the high-volume, "grunt work" tasks of file navigation and editing. However, it is equipped with a new tool: ask_expert.

SWE-Protégé Post-Training Pipeline and Trajectory Evolution

The training process consists of two phases:

  1. Phase I: Supervised Induction (SFT): The model is fine-tuned on trajectories where a strong expert model provided guidance. This phase teaches the SLM the mechanics of collaboration: how to formulate useful questions and how to interpret and act upon expert advice.
  2. Phase II: Agentic Reinforcement Learning (RL): Using Group Relative Policy Optimization (GRPO), the model's behavior is refined through a composite reward system. This system penalizes stalling (looping), rewards "warranted" escalation (calling the expert only when stuck), and rewards follow-through (ensuring the model actually implements the advice received).

This "Junior Partner" paradigm allows for asymmetric information exchange. The expert does not need the full conversation history; a compact summary of recent turns is sufficient to provide high-level intuition, keeping token costs low.

Experimental Results

The framework was evaluated primarily on SWE-bench Verified, a set of 500 human-vetted real-world GitHub issues. Training data included trajectories from SWE-smith and reinforcement learning tasks from SWE-Gym.

Performance Scaling and Token Efficiency of SWE-Protégé

The results demonstrate a significant breakthrough for SLMs:

  • State-of-the-Art Performance: A Qwen2.5-Coder-7B model trained with SWE-Protégé achieved a 42.4% Pass@1 on SWE-bench Verified. This represents a 25.4% improvement over the previous best SLM and rivals the performance of 70B-parameter models.
  • Cost and Efficiency: The system is 8.2x cheaper than using an expert model (like Claude 3.5 Sonnet) exclusively. The RL phase significantly improved decisiveness, reducing the average steps per task from approximately 60 to 20.
  • Selective Escalation: The model learned to use the expert sparsely, averaging only 4 calls per task, which accounted for just 11% of the total tokens used.

Discussion and Future Work

The success of SWE-Protégé highlights that "behavioral hygiene"—specifically the suppression of degenerative looping—is as critical as raw coding capability for agentic SLMs. By focusing on collaboration rather than solo performance, the framework unlocks the potential of smaller, more efficient models.

Future work may explore "co-adaptation," where the expert model is also tuned to be a more effective mentor. Additionally, while currently focused on software engineering, the expert-protégé paradigm could be extended to other complex agentic domains such as web navigation or scientific research. Finally, the authors envision this system evolving to include humans as the "expert," facilitating a seamless transition between autonomous AI and human-steered development.

Summary updated

Abstract

Small language models (SLMs) offer compelling advantages in cost, latency, and adaptability, but have so far 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 sole 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, 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).
BibTeX
@misc{kon2026swe,
  author = {Patrick Tser Jern Kon and Archana Pradeep and Ang Chen and Alexander P. Ellis and Warren A. Hunt and Zijian Wang and John Yang and Samuel Thompson},
  title = {{SWE-Protégé: Learning to Selectively Collaborate With an Expert Unlocks Small Language Models as Software Engineering Agents}},
  year = {2026},
  eprint = {2602.22124},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.22124},
}
Figure