Agentic AI
New Framework Uses Reusable Code Modules to Automate Large-Scale Repository Construction
Researchers introduce LEGO, a system that leverages composable code primitives to help AI models build complete software repositories at scale.
Scaling up AI-assisted code generation from individual functions to entire software repositories remains challenging, particularly when dealing with complex interdependencies, configurations, and test validation. A new research paper proposes a practical solution through reusable, self-contained code components that adapt to their target environment.
The Problem: Complexity at Scale#
Building production-ready repositories involves far more than generating isolated code snippets. Developers must orchestrate interacting modules, maintain compatible interfaces, manage dependencies, validate against test suites, and track the provenance of components. While large language models paired with development tools have made progress toward repository-scale construction, successfully assembling a complete, functioning system remains difficult.
Introducing Code Primitives and LEGO#
The researchers introduce two key innovations. Code Primitives are reusable, executable components bundled with interface specifications, dependency information, validation tests, and metadata about their origin. Crucially, each primitive carries a resident LLM capability that allows it to assess whether it's relevant to a specific task and automatically adapt its implementation, interfaces, and dependencies to fit the target repository.
The team organized 1,424 validated primitives into CodeFace, a searchable library designed for repository construction. Building on this foundation, they developed LEGO (Large-scale repository Engineering via aGent-native reusable cOde primitives), a system that:
- Identifies which primitives are relevant to a development task
- Integrates their adapted implementations alongside custom code
- Resolves conflicts and constraints across components
- Refines results by running actual test suites
Measuring Success: LEGO-REPO Benchmark#
To rigorously evaluate the approach, researchers created LEGO-REPO, a benchmark containing 522 executable repository reconstruction tasks. The benchmark spans seven software domains, 22 capability tracks, and five difficulty levels, with performance scored against actual test suites relative to both an empty baseline and the original source code as an upper ceiling.

