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

Executing as You Generate: Hiding Execution Latency in LLM Code Interpreters

Zhensu Sun, Zhihao Lin, Zhi Chen, Chengran Yang, Mingyi Zhou, Li Li, David LoarXiv 2026

TL;DR

EAGER (Executing As you GEneRate) is a framework that slashes the latency of LLM code interpreters by overlapping code generation with execution. By identifying and running complete code "chunks" as they are streamed, EAGER hides up to 90% of execution time behind the generation process, reducing end-to-end latency by up to 37% and significantly improving the success rate of subsequent code repairs.

What Problem Does This Paper Address?

Modern AI agents often use "code interpreters" to perform data analysis or solve math problems. Currently, this process is strictly serial: the LLM generates the entire script, and only then does the system run it. This creates a "double wait" for the user—first for the text to appear, then for the code to execute.

The authors observe that unlike humans, who might jump back to edit earlier lines, LLMs generate code tokens strictly from left to right. This means that once a complete statement (like an import or a variable assignment) is generated, it is final. Waiting for the end of a 50-line script to run the first 5 lines is fundamentally inefficient. The challenge lies in safely and accurately identifying these "executable chunks" in real-time without breaking the program's logic or side effects.

Methods

The authors introduce EAGER, a three-stage pipeline (Generation $\rightarrow$ Detection $\rightarrow$ Execution) designed to parallelize the workflow.

Fig. 2: Architecture of EAGER.

Key technical components include:

  • AST-Based Chunking: Instead of simple line-splitting, EAGER uses Abstract Syntax Tree (AST) parsing to identify syntactically complete top-level statements. It employs a "lookahead" strategy to distinguish between a finished statement and one that might continue (like the start of a function body).
  • Gated Execution: To preserve program semantics, EAGER uses a "gating policy." Chunks involving external side effects (e.g., filesystem mutation, networking) or timing-sensitive operations (e.g., sleep, threading) are deferred to run serially, ensuring the program behaves exactly as it would in a standard environment.
  • Dynamic Batching: If the LLM generates code faster than the interpreter can run it, EAGER merges pending chunks into a single batch to minimize the overhead of multiple interpreter calls.
  • Early Error Interruption: If a chunk fails during execution, EAGER immediately kills the generation process. This prevents the model from wasting time generating code that relies on a failed state.

Datasets

The researchers evaluated EAGER across four diverse Python benchmarks using seven different LLMs (including DeepSeek-V3, GPT-4o-mini, and Gemini-3.1-Flash):

  • DSBench & DABench: Realistic data science and analysis tasks involving multi-table structures and CSV files.
  • PandasPlotBench: A human-curated benchmark for data visualization code.
  • GitChameleon: A benchmark testing version-specific library compatibility, where code completion depends on specific dependency versions.

Key Insights and Ideas

  • Hiding Latency in Plain Sight: For most LLM tasks, generation time is the bottleneck. By "hiding" execution within that generation window, the user-perceived execution time can effectively drop to near zero.
  • The "Anchoring" Problem: In serial systems, when an error occurs early, the LLM continues generating a "post-error suffix." When asked to fix the code, the model is often "anchored" by this flawed suffix. EAGER's early interruption provides a "Partial" code context that gives the model more freedom to regenerate a correct solution from the point of failure.
  • Operating Regimes: The paper identifies three regimes: Generation-dominated (where EAGER shines), Execution-dominated (where latency savings are minimal), and Balanced. Most current LLM interpreter tasks fall into the generation-dominated category.

Key Results

The results show that parallel execution is highly effective across various models and environments (Local, Docker, and Open Interpreter).

Fig. 1: An illustrative example comparing Serial Execution and Parallel Execution. For a code snippet with four chunks, Parallel Execution overlaps the first three chunks with the generation process, saving the corresponding waiting time.
  • Latency Reduction: EAGER reduces the "non-overlapped" execution time by an average of 89.8%. On error-free runs, this translates to an end-to-end latency saving of up to 37.3%.
  • Error Handling: For scripts that encounter errors, the savings are even more dramatic—up to 75%—because the system stops generating immediately upon failure.
  • Improved Repair: On data-centric benchmarks, providing the model with early error feedback on partial code (rather than the full failed script) improved the success rate of subsequent code repairs by up to 44.3 percentage points.

Limitations and Future Work

  • Scope: EAGER is optimized for "script-style" generation (single-file data analysis). It is less suited for "execution-heavy" tasks like compiling large software repositories or running extensive test suites.
  • Language Support: While the principles are language-agnostic, the current implementation is Python-specific.
  • Future Design: The authors suggest that future programming languages could be designed with "streamability" as a first-class goal, using explicit delimiters to make incremental execution even easier for AI systems.

Summary updated

BibTeX
@misc{sun2026executing,
  author = {Zhensu Sun and Zhihao Lin and Zhi Chen and Chengran Yang and Mingyi Zhou and Li Li and David Lo},
  title = {{Executing as You Generate: Hiding Execution Latency in LLM Code Interpreters}},
  year = {2026},
  eprint = {2604.00491},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.00491},
}
Figure