TL;DR
AI coding agents are revolutionizing software development, but they frequently generate code containing subtle runtime errors. REDO (Execution-free Runtime Error Detection for COding Agents) solves this by combining the precision of traditional static analysis with the contextual reasoning of Large Language Models (LLMs)—all without executing a single line of code.
What Problem Does This Paper Address?
While state-of-the-art LLM coding agents excel at understanding problem statements and generating code patches, they are highly prone to introducing runtime errors (like TypeError or AttributeError).
To catch these bugs before deployment, developers typically rely on two approaches, both of which have severe limitations:
- Static Analysis Tools (e.g., PyRight, Pylint): These are fast but struggle with dynamically typed languages like Python. They cannot reason about runtime input contexts, leading to high false-positive rates or missed dynamic errors (low recall).
- Dynamic Analysis (Code Execution): Running the code in a sandbox catches errors reliably, but it is computationally expensive, presents security and privacy risks, requires complex environment configurations, and halts at the very first error encountered—missing any subsequent bugs.
REDO addresses this gap by providing a lightweight, execution-free verification pipeline that filters out broken code patches early, saving time and compute costs.
Methods
REDO employs a clever two-step pipeline that balances the reliability of hard-coded rules with the broad reasoning capabilities of LLMs:
- Differential Analysis (Static Phase): Instead of just running a static analyzer on the new code patch, REDO runs it on both the original implementation and the modified implementation. By comparing the two error sets ($S_{Orig}$ vs $S_{Mod}$), it isolates only the new errors introduced by the agent. This simple trick eliminates nearly all the false positives typically triggered by missing stubs or environment configurations in large repositories. If a new error is found, the patch is immediately rejected as "Unsafe."
- LLM-Based Detection (Semantic Phase): If the static analyzer deems the patch "Safe," it is passed to an LLM (Claude-3.5-Sonnet). The LLM is provided with the natural language problem statement, the original code context, and the modification patch. This allows the model to reason about input types and edge cases that static tools inherently miss.
Datasets
The authors evaluated REDO on two distinct benchmarks:
- SWEDE (SWE-Bench-Error-Detection): A novel benchmark introduced in this paper. Built on top of SWE-Bench (lite), SWEDE evaluates repository-level error detection in the presence of complex external dependencies. It features real-world patches generated by six top-tier coding agents (including CodeStory, Aider, and AutoCoderRover).
- STA Dataset: A baseline dataset consisting of roughly 27,000 Python submissions for competitive programming tasks, evaluated in both "With Context" (with standard input descriptions) and "Without Context" scenarios.
Key Insights and Ideas
- The Complementary Tool Synergy: Static analysis tools have high precision but narrow scope (low recall). LLMs have a wide scope (high recall) but can occasionally hallucinate or misreason (lower precision). Restricting the LLM to evaluate only the instances cleared by static analysis maximizes the strengths of both.
- The Power of Differential Analysis: Running static analysis directly on raw repository files falsely flagged up to 89% of safe instances as "Unsafe" due to missing environmental context. Shifting to a differential approach completely neutralized this issue.
- Context is King for LLMs: LLMs excel at catching dynamic errors because they can read the natural language problem description. For example, if a problem statement implies an input could be a custom object missing an
.emailattribute, the LLM can foresee anAttributeErrorthat a static type-checker cannot deduce from the code alone.
Key Results
REDO achieved state-of-the-art performance across multiple benchmarks, outperforming existing Graph Neural Network (GNN) and Transformer baselines:
- Performance Leap: On the STA dataset, REDO outperformed previous state-of-the-art methods by 11.0% in accuracy and 9.1% in weighted F1 score when input context was provided.
- Consistency Across Agents: On the newly proposed SWEDE benchmark, REDO consistently achieved the highest F1 scores regardless of which coding agent generated the underlying patch.
- Efficiency Gains: Because the static analysis phase filters out obviously broken patches first, REDO significantly reduces the number of expensive LLM API calls required during agent iteration loops.
Limitations and Future Work
Despite its strong performance, the authors note a few areas for improvement:
- API Call Constraints: The current LLM phase is restricted to a single API call per instance to keep latency low. Transitioning to a multi-turn, agentic loop could further boost accuracy.
- Binary Classification: On the SWEDE benchmark, REDO currently acts as a binary classifier ('Safe' vs 'Unsafe'). Expanding its capability to output specific error types (as it does on the STA dataset) would provide better feedback for patch-fixing.
- Iterative Patch Fixing: While the paper demonstrates a preliminary patch-fixing loop using REDO's error descriptions, fully integrating this into an autonomous, iterative self-healing agent remains future work.
Summary updated