NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

L2MAC: Large Language Model Automatic Computer for Extensive Code Generation

Samuel Holt, Max Ruiz Luyten, Mihaela van der Schaar

Introduction

L2MAC is a novel framework that transforms Large Language Models (LLMs) into "automatic computers" based on the classic von Neumann architecture. By breaking complex tasks into a structured "prompt program" and managing a persistent file store, it enables LLMs to generate massive, internally consistent outputs—like entire multi-file codebases or full-length books—that far exceed their native context window limits.

The Problem: Context Window Constraints

The "context window" is the Achilles' heel of modern Transformer-based LLMs. Even the most powerful models can only process a fixed number of tokens at once. When tasked with building a large software system, an LLM often loses the thread: it forgets the variables defined in the first file by the time it reaches the fifth, leading to code that is fragmented and broken.

Existing solutions like "memory-augmented" LLMs usually just append new information to a long list, which eventually overflows the context window anyway. Other "autonomous agents" (like AutoGPT) tend to "drift" from the user's original goal because they are constantly re-planning their steps without a stable, long-term memory of the project's global state. L2MAC aims to bridge this gap by providing a structured way to read, write, and verify a large-scale project across many sequential steps.

Methods: The L2MAC Architecture

The authors introduce the Large Language Model Automatic Computer (L2MAC). It mimics a stored-program computer with three core components:

L2MAC Architecture and Workflow
  1. Instruction Registry (The Program): Instead of one giant prompt, the LLM first generates a detailed, sequential list of sub-tasks (a "prompt program").
  2. File Store (The Memory): A persistent storage area where the LLM can create, read, and—crucially—update files. This allows for in-place modifications, much like a real programmer editing a script.
  3. Control Unit (The Orchestrator): This is the "brain" of the framework. It manages the LLM's context window for each sub-task. It ensures the LLM sees the current instruction, a summary of previous progress, and any relevant files from the store.

The Workflow: For each instruction, the Control Unit spawns an LLM agent. The agent uses tools to interact with the file store. Once a task is "complete," the Control Unit runs an Evaluator (e.g., a syntax checker or unit test suite). If the code fails, the error is fed back to the agent to fix. Only when the code passes all checks does the system summarize the work and move to the next instruction.

Key Insights

  • Automatic vs. Autonomous: The authors argue that for complex tasks, we need automatic systems (which follow a pre-defined program strictly) rather than autonomous ones (which might wander off-task). L2MAC stays grounded by adhering to its initial instruction registry.
  • The Power of the Update: Most LLM agents are "append-only." L2MAC’s ability to go back and refactor an existing file is what allows it to maintain consistency in a large codebase.
  • Self-Correction via Unit Tests: L2MAC doesn't just hope the code works; it is instructed to write its own unit tests. The Control Unit uses these tests as a hard gate, forcing the model to iterate until the logic is actually functional.
  • Context Management: By summarizing the output of each step and "clearing" the context window between instructions, L2MAC bypasses the physical token limits of the underlying Transformer.

Evaluation and Key Results

The authors evaluated L2MAC using HumanEval (an industry-standard benchmark for standalone Python functions), a custom System Design Benchmark (requiring the building of entire applications from scratch), and a general text generation task (writing a complete recipe book).

System Design Benchmark Results
  • State-of-the-Art Coding: L2MAC achieved a 90.2% Pass@1 score on HumanEval, outperforming standalone GPT-4 and other specialized coding agents.
  • Feature Completion: In the System Design tasks, L2MAC implemented 91.6% of requested features for the URL Shortener, while the popular AutoGPT managed only 25.3%.
  • Scale: L2MAC successfully generated codebases exceeding 1,000 lines of code, maintaining functional consistency across multiple files—a feat where most single-prompt LLMs fail.
  • Coherent Long-Form Text: The framework produced a multi-chapter book where the index, glossary, and chapters were all internally consistent.

Limitations and Future Work

While highly effective, L2MAC has a few limitations:

  • LLM Reasoning Ceiling: L2MAC is still limited by the "intelligence" of the underlying model (e.g., GPT-4). If the model can't solve a specific logic puzzle, the framework can't fix that.
  • File List Bottleneck: Currently, the Control Unit lists all file names in the context window. For projects with thousands of files, this would eventually exceed the context limit. Moving to a hierarchical file system (folders) could solve this.
  • Token Efficiency: Rewriting entire files for small changes is expensive and slow. Future versions could use "diffs" (like Git) to only send and receive the changed lines of code.

Future work will explore expanding L2MAC into non-coding domains, such as automated mathematical theorem proving.

Summary updated

BibTeX
@inproceedings{holt2024l,
  author = {Samuel Holt and Max Ruiz Luyten and Mihaela van der Schaar},
  title = {{L2MAC: Large Language Model Automatic Computer for Extensive Code Generation}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=EhrzQwsV4K},
}
Figure