SpecForge: Recursive Self-Improvement for Coding Agents via Behavioral Specifications
Abstract
Coding agents based on frozen language models can improve their performance by refining the external context they rely on, without updating model weights. We study recursive self-improvement through behavioral specifications: natural-language code documentation that describes the behavior of program entities and guides agents in generating correct code. We formulate a self-improvement loop in which an agent generates code from its current specifications, evaluates it with execution-verified tests, and refines the specifications based on observed failures. The improved specifications then guide subsequent generation, progressively improving the agent's understanding of the codebase. However, recursive refinement is challenging because program entities are interdependent. Improving the specification of one entity can inadvertently degrade the correctness of others, a phenomenon we call output coupling. This creates a whack-a-mole effect in which local improvements cause regressions elsewhere, preventing consistent progress. We introduce SpecForge, a multi-frontier tree search framework that addresses this challenge with three mechanisms: (i) Pareto-guided state selection preserves complementary specification states and prevents premature commitment; (ii) dependency-constrained entity selection prioritizes callee-before-caller refinement; and (iii) error-diversified expansion explores multiple refinements using different subsets of test failures. On DevEval+, SpecForge achieves the best performance across five backbone models, including a 94.9% solve rate with Claude-4.5-Sonnet and a 5.7-percentage-point average improvement over the strongest baseline. The improved specifications also make the agent better at tasks outside the loop: they transfer to cross-language translation and to new-feature implementation, where they outperform the benchmark-provided requirement documents.
Create a lesson
Metadata
- Categories
- cs.AI, cs.SE
- Comments
- Accepted to NeurIPS 2026 (Main Track)
Related papers
Fin-RSI: A Unified Library of Financial Skills, Checks, and Self-Improvement for LLM Agents
Shared title terminologycs.AIWanghao Ye, Shwai He, Sihan Chen et al.
Improving the Improver: Semantic PID Control for Medical Agent Self-Improvement
Shared title terminologycs.AIDexia Chen, YiLong Hu, Wenqi Zhong et al.
Diversity over Scale: Recursive Self-Improvement with Ensembles of Small Open-Weight Models
Shared title terminologycs.AINavapat Nananukul, Mayank Kejriwal
FinEvo: Recursive Self-Improvement for Long-Horizon Financial Modeling
Shared title terminologycs.AIChengjun Pan, Shichun Liu, Zekai Zhou et al.
Pre-Registered Genesis Accounting for Recursive Self-Improvement: First Audited Operator-Genesis Events in a Physics-Discovery Runtime
Shared title terminologycs.AIWenbin Mao, Pei Zou
From Existing Methods to New Research Ideas: Two Perspectives on Recursive Self-Improvement
Shared title terminologycs.AILeijun Zhou, Yanke Yu, Zhihao Liu et al.