TL;DR
This paper introduces Devstral-Small, a 24B parameter language model specifically fine-tuned for coding agent applications. It achieves state-of-the-art performance among open-source models under 100B parameters on agentic coding tasks, demonstrating that specialized training can yield impressive results even with smaller model sizes.
What Problem Does This Paper Address?
The field of AI for code generation has seen rapid advancements, with large language models (LLMs) excelling at tasks like code completion and generation. However, a significant gap exists in enabling LLMs to act as autonomous "coding agents" capable of complex, multi-step software engineering workflows. These agents need to not only write code but also understand project context, reason through problems, interact with development environments, and integrate with tools. While closed-source models have made strides in this area, open-source alternatives have lagged, often struggling with the iterative and context-aware nature of agentic tasks. This paper aims to bridge this gap by developing a high-performing, open-source coding agent model.
Methods
The core of Devstral-Small is a 24B parameter dense Transformer model, built upon Mistral Small 3. It features 40 layers and grouped query attention. The model undergoes a two-stage training process:
- Pre-training: The model is initially trained on a diverse mix of natural language and code. A long context extension phase boosts its context window to 128k tokens, crucial for understanding larger codebases.
- Agentic Fine-tuning: This is the key innovation. The model is fine-tuned using supervised trajectories generated by an agent operating within the SWE-Gym environments, specifically using the OpenHands CodeAct scaffold. This process involves:
- Supervised Trajectories: An agent interacts with a coding environment, alternating between chain-of-thought reasoning and actions. Unit tests are used to verify the quality of generated code patches.
- Two-Stage Training: The model is first trained on a larger set of rollouts meeting a heuristic quality filter, then fine-tuned on trajectories passing stricter filters.
- Policy Optimization: Additional rounds of rollouts with the fine-tuned model are used for further training via policy optimization.
The evaluation setup uses the OpenHands scaffold, providing agents with bash execution and file editing tools, mimicking human software engineers.
Datasets
- Training Data: The paper mentions pre-training on "diverse sources of text including both natural language and code." For agentic fine-tuning, supervised trajectories are generated using the SWE-Gym environments and the OpenHands CodeAct scaffold.
- Evaluation Benchmarks: The primary benchmark used is SWE-bench Verified. The paper also compares results against reported SWE-Bench performance on custom scaffolds for models like GPT-4.1-mini and Claude 3.5 Haiku, and SWE-smith on the SWE-Agent scaffold.
Key Insights and Ideas
- Specialization is Key: The paper strongly suggests that fine-tuning specifically for agentic tasks, rather than general code completion, is crucial for achieving high performance in software engineering workflows.
- Size Isn't Everything: Devstral-Small, at 24B parameters, demonstrates that smaller models can achieve state-of-the-art results when appropriately trained and specialized, outperforming models orders of magnitude larger.
- Iterative Evaluation Protocol: The use of an iterative evaluation protocol (allowing up to 3 attempts with varying temperatures) is shown to provide stable and reliable performance metrics with fewer executions compared to traditional averaging methods. This is particularly important for the stochastic nature of LLM agents.
- Temperature Scaling Nuances: Counter-intuitively, higher temperatures (more stochasticity) did not consistently lead to better scaling with increased K in the Pass@K metric for agentic tasks, unlike in competitive programming. Lower temperatures showed more consistent improvement with higher K.
Key Results
- State-of-the-Art Performance: Devstral-Small achieves state-of-the-art results among open models under 100B parameters on the OpenHands scaffold, outperforming models like Qwen 3 (235B) and DeepSeek-V3.
- Competitive with Larger Models: It significantly outperforms smaller closed models like GPT-4.1-mini by over 20%.
- Optimal Iteration Limit: 50 iterations appear to be an optimal balance between computational budget and performance, with no significant gains observed beyond this limit.
- Temperature Effects: While Pass@1 performance is similar across temperatures, higher K values show that lower temperatures lead to more consistent improvements.
Limitations and Future Work
- Limitations:
- The paper acknowledges that even with temperature 0, sources of nondeterminism persist due to underlying hardware implementation details.
- The evaluation protocol, while robust, could explore more advanced refinement strategies.
- Future Work:
- The authors suggest exploring more advanced refinement strategies for agentic evaluation.
- The paper mentions a refreshed version, Devstral-Small-2507, showing further improvements, indicating a clear path for developing better models through high-quality data and iterative refinement.
- The potential for easily deployable, lightweight models like Devstral-Small on local devices is highlighted.
Summary updated