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

SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?

Noam Tarshish, Nofar Selouk, Daniel Hodisan, Bar Ezra Gafniel, Yuval Elovici, Asaf Shabtai, Eliya NachmaniarXiv 2026

TL;DR

SAFEdit is a multi-agent framework that tackles the tricky task of instruction-driven code editing by breaking it down into three specialized roles: a Planner, an Editor, and a Verifier. By combining this role separation with a structured Failure Abstraction Layer for test-driven refinement, SAFEdit achieves a 68.6% success rate on EditBench, outperforming single-agent baselines and completely eliminating regression errors.

What Problem Does This Paper Address?

While Large Language Models (LLMs) excel at generating code from scratch, they frequently stumble when asked to modify existing code. This task—known as instructed code editing—requires a model to precisely implement a natural language instruction (like fixing a bug or adding a parameter) while preserving the rest of the codebase and satisfying pre-existing unit tests.

Recent benchmarks reveal a stark reality: even frontier models struggle here. On the EditBench dataset, 39 out of 40 evaluated models failed to clear a 60% task success rate. Monolithic or single-agent approaches (like the ReAct paradigm) often suffer from "over-editing" (making unnecessary cosmetic changes that break things), instruction hallucination, or introducing regression errors that destroy previously working functionality.

Methods

The authors introduce SAFEdit (Structured Agentic Framework for Trustworthy Code Editing), which replaces a single monolithic LLM loop with three specialized agents orchestrated via the CrewAI framework:

  1. Planner Agent: Consumes the instruction and context to generate a structured, code-free edit plan detailing the intent, target location, and explicit constraints.
  2. Editor Agent: Takes the plan and original code to apply minimal, literal modifications. It is strictly forbidden from doing arbitrary refactoring.
  3. Verifier Agent: Executes the modified code against actual unit tests within a secure, sandboxed environment.
Figure 1: Overview of the SAFEdit framework. The pipeline organizes the editing task into three specialized agents (Planner, Editor, Verifier), which are connected in an iterative refinement loop. The FAL transforms raw test output into structured feedback, and the error taxonomy classifies failure root causes for qualitative analysis.

If a test fails, SAFEdit doesn't just pass raw, noisy compiler logs back to the model. Instead, it routes them through a deterministic Failure Abstraction Layer (FAL). The FAL parses the logs, classifies the error into one of 14 categories (e.g., SYNTAX_ERROR, ASSERTION_MISMATCH), and generates a clean, structured diagnostic block explaining what failed, why, and a suggested action. This feedback is fed back to the Editor for up to three refinement iterations.

Datasets

The framework was evaluated using EditBench, a benchmark containing real-world code-editing tasks across Python and JavaScript sourced from developer IDE sessions.

To ensure a clean evaluation, the authors filtered the dataset down to 445 tasks (removing records with identical code variants or malformed test suites). To test multilingual robustness, these tasks were evaluated across five natural languages: English, Polish, Spanish, Chinese, and Russian. Tasks were also split across three spatial visibility variants: Code Only (file-level), Highlight (function-level), and Highlight + Cursor (line-level).

Key Insights and Ideas

  • Role Separation Beats Raw Scale: Even when holding the underlying model constant (using GPT-4), splitting the cognitive load between a Planner and an Editor yielded massive reliability gains. Preventing the Editor from thinking about what to do and forcing it to focus purely on how to execute a literal plan keeps it grounded.
  • The Cure for Regressions: Remarkably, SAFEdit achieved a 0% Regression Error rate across all tested languages. Monolithic single-agent baselines frequently broke existing functionality while trying to fix a bug; SAFEdit’s constrained editing protocol completely eliminated this behavior.
  • The Context Paradox: In single-agent systems, providing more precise spatial context (like a cursor position) can counterintuitively degrade performance by introducing prompt noise. SAFEdit proved highly robust to these variations because its Planner standardizes the context into a stable edit plan before any code is touched.

Key Results

  • State-of-the-Art Performance: Under the standard Highlight variant, SAFEdit achieved an overall 68.6% Task Success Rate (TSR), outperforming the best single-model baseline on the EditBench leaderboard (Claude-Sonnet-4 at 64.8%) and a GPT-4-based ReAct baseline (60.0%).
Figure 2: TSR under the HIGHLIGHT visibility variant for SAFEdit, ReAct baseline, and top-5 EditBench leaderboards baselines.
  • Power of the Refinement Loop: The iterative refinement loop was the primary engine of success, contributing an average of +17.4 percentage points over first-pass attempts.
  • Multilingual Consistency: SAFEdit consistently beat the ReAct baseline across all five natural languages, showing that its structured planning phase successfully mitigates the ambiguity often introduced by multilingual instructions.
Figure 3: Stacked error distribution (%) for failed tasks tests across the evaluated languages. For each language, SAFEdit multi- agent decomposition (left) and ReAct implementation (right) are broken down into the root-cause categories of IH, IG, RE, and CM. The figure does not include the EditBench models because it does not report results for each language.

Limitations and Future Work

  • Localized Scope: The evaluation was restricted to localized edits within single files. Real-world software engineering often requires repository-level editing, where a change in one file must propagate across multiple files and dependencies.
  • Computational Overhead: Reliability comes at a cost. SAFEdit requires a minimum of three sequential LLM calls per task, which can scale up to five or six calls during iterative refinement. This makes it significantly slower and more expensive than single-shot generation.
  • Future Directions: The authors suggest expanding the framework to handle longer-horizon repository-level changes, testing it with a wider variety of backbone LLMs, and incorporating human validation to refine their automated failure taxonomy.

Summary updated

BibTeX
@misc{tarshish2026safedit,
  author = {Noam Tarshish and Nofar Selouk and Daniel Hodisan and Bar Ezra Gafniel and Yuval Elovici and Asaf Shabtai and Eliya Nachmani},
  title = {{SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?}},
  year = {2026},
  eprint = {2604.25737},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.25737},
}
Figure