Papers
Topics
Authors
Recent
Search
2000 character limit reached

RefAgent: Multi-Agent Software Refactoring

Updated 16 July 2026
  • RefAgent is a framework that automates software refactoring through multiple specialized LLM-based agents.
  • It employs a role-specialized workflow—planning, generation, compilation, and testing—to iteratively refine code while preserving behavior.
  • Evaluations on Apache Java projects show improved unit test pass rates, significant code smell reductions, and enhanced reusability.

Searching arXiv for the cited systems and closely related uses of “RefAgent” to ground the article. RefAgent most precisely denotes the multi-agent LLM-based framework for end-to-end software refactoring introduced in "RefAgent: A Multi-agent LLM-based Framework for Automatic Software Refactoring" (Oueslati et al., 5 Nov 2025). In adjacent arXiv usage, however, the label also appears in a broader descriptive sense for explicit reasoning-and-tool-use agents, while several similarly named systems—notably ReAgent, ReAgent-V, and Refer-Agent—are separate frameworks rather than variants of RefAgent (Zhao et al., 10 Mar 2025, Zhou et al., 2 Jun 2025, Jiang et al., 3 Feb 2026). The term therefore has a dual status in current literature: a concrete software-engineering system, and a looser agentic motif organized around decomposition, specialized roles, tool invocation, reflection, memory, and iterative correction (Zhou et al., 6 Aug 2025, Shang et al., 26 May 2025).

1. Nomenclature and scope

The most important terminological distinction is between RefAgent and several near-homographic systems. The software-refactoring framework is formally named RefAgent (Oueslati et al., 5 Nov 2025). By contrast, the multi-hop QA system is formally named ReAgent, not RefAgent, and the paper explicitly states that “RefAgent” is not part of that work (Zhao et al., 10 Mar 2025). The referring video object segmentation system is Refer-Agent (Jiang et al., 3 Feb 2026), and the reward-driven video understanding system is ReAgent-V (Zhou et al., 2 Jun 2025). In referring audio-visual segmentation, the paper does not introduce a system called RefAgent either; instead, it presents TGS-Agent and describes a “RefAgent” paradigm as an explicit reasoning-first approach (Zhou et al., 6 Aug 2025).

Name Domain Status of the term
RefAgent Automatic software refactoring Formal system name
TGS-Agent / “RefAgent” paradigm Referring audio-visual segmentation Descriptive paradigm; formal system is TGS-Agent
Constructed “RefAgent” in AgentRecBench synthesis Personalized recommendation Reference design; not a formal paper system
ReAgent Knowledge-enhanced multi-hop QA Distinct framework, not RefAgent
ReAgent-V Video understanding Distinct framework, not RefAgent
Refer-Agent Referring video object segmentation Distinct framework, not RefAgent

This naming overlap matters because the underlying technical commitments differ sharply. The software RefAgent is centered on source-code transformation and behavior preservation (Oueslati et al., 5 Nov 2025), whereas the similarly named systems emphasize reversible reasoning (Zhao et al., 10 Mar 2025), reward-driven reflection (Zhou et al., 2 Jun 2025), segmentation-oriented reasoning and grounding (Zhou et al., 6 Aug 2025), or query-faithful video mask generation (Jiang et al., 3 Feb 2026).

2. RefAgent as an automated software-refactoring system

In its strictest sense, RefAgent is a fully automated, multi-agent system that uses specialized LLM-based agents with tool-calling and self-reflection to plan, apply, validate, and iteratively refine software refactorings while preserving behavior (Oueslati et al., 5 Nov 2025). The framework was evaluated on eight large, real-world Apache Java projects and benchmarked against single-agent LLMs, a search-based refactoring tool, and historical developer refactorings.

Its architecture is role-specialized. The Context-aware Planner Agent consumes the target class, project path, dependency information from jdeps, and software metrics from DesigniteJava 2.5.2 to identify refactoring opportunities and emit a structured plan. The Refactoring Generator Agent applies that plan to produce refactored Java source and later revises it in response to compile or test feedback. The Compiler Agent invokes the Maven compiler, summarizes failures, and initiates correction loops. The Tester Agent executes developer-written tests together with EvoSuite-generated regression tests and similarly feeds failures back into the generator for further repair (Oueslati et al., 5 Nov 2025).

The framework’s tooling is integral rather than auxiliary. jdeps supplies class-level dependency graphs for both planning and test discovery; DesigniteJava contributes metrics such as cyclomatic complexity, cohesion, and coupling; Maven provides compilation and testing feedback; EvoSuite generates regression tests from the original program; and RefactoringMiner 3.0 is used in evaluation to identify refactoring types and locations (Oueslati et al., 5 Nov 2025). A notable design choice is that the planner uses metrics only, not smell labels, to avoid bias from a fixed smell taxonomy.

3. Execution model, validation loop, and acceptance criteria

RefAgent operates as a class-by-class workflow. For each selected target class, the planner retrieves first-degree dependencies and contextual metrics, the generator produces an initial refactoring, the compiler attempts a build, and the tester runs validation suites. Compilation and testing are both guarded by self-reflective correction loops with a maximum of 20 iterations each (Oueslati et al., 5 Nov 2025). If compilation or test failures persist after the iteration cap, the class is skipped so that the pipeline can continue through the project.

Behavior preservation is enforced through a strict acceptance gate. A refactoring is accepted only if compilation succeeds and all applicable developer and EvoSuite tests pass. The reported validation metrics include the unit test pass rate,

PassRate=#passed tests#total tests×100%,\mathrm{PassRate} = \frac{\#\text{passed tests}}{\#\text{total tests}} \times 100\%,

and a code smell reduction metric,

%Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,

together with QMOOD attribute improvements such as

QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.

The paper also reports QMOOD attribute formulas including reusability, flexibility, understandability, effectiveness, extendibility, and functionality (Oueslati et al., 5 Nov 2025).

This workflow places compilation and testing inside the agent loop rather than after it. That is the key operational difference between RefAgent and single-pass code-editing systems: compiler and test outputs become first-class control signals for iterative plan repair rather than merely ex post diagnostics (Oueslati et al., 5 Nov 2025).

4. Empirical performance and observed refactoring behavior

On the eight-project evaluation, RefAgent achieved a median unit test pass rate of 90%, a median code smell reduction of 52.5%, and a median reusability improvement of 8.6% (Oueslati et al., 5 Nov 2025). In identifying refactoring opportunities, it attained a median F1-score of 79.15% against developer refactorings and 72.7% against the search-based tool RefGen. Relative to single-agent approaches, it improved the median unit test pass rate by 64.7% and the median compilation success rate by 40.1% (Oueslati et al., 5 Nov 2025).

Across backbone models, the reported median values were close: GPT-4o reached unit-test pass 90, compilation pass 87, and smell reduction 52.5; StarCoder2 reached 85, 84, and 50; DeepSeekCoder reached 90, 88, and 53.5. Wilcoxon tests reported significant gains over single-agent baselines on core metrics, while differences across the three backbones were not statistically significant at the reported thresholds (Oueslati et al., 5 Nov 2025).

The framework’s qualitative refactoring repertoire spans 23 refactoring types, including Extract Method, Invert Condition, Parameterize Variable, Merge Conditional, Rename Attribute, Change Method Access Modifier, Remove Variable Modifier, and Replace Conditional With Ternary (Oueslati et al., 5 Nov 2025). The accompanying empirical study "How do Agents Refactor: An Empirical Study" provides a complementary external lens on agentic refactoring practice: across 86 Java projects per group, agent refactorings in the wild were dominated by annotation-related changes, whereas developers exhibited more diverse structural refactorings. In that study, Cursor was the only agent with a statistically significant increase in smell counts after refactoring commits, with p=0.013p = 0.013 and Cliff’s Δ=0.51\Delta = 0.51 (Ottenhof et al., 28 Jan 2026). This suggests that RefAgent’s explicit compile–test–repair loop addresses a failure mode visible in uncontrolled agentic refactoring behavior.

5. RefAgent as a broader agentic design pattern

Beyond software engineering, “RefAgent” is used more loosely to describe explicit reasoning-first agents that expose intermediate representations and orchestrate external tools. In referring audio-visual segmentation, "Think Before You Segment" presents TGS-Agent, which instantiates a RefAgent-like paradigm through a Think–Ground–Segment decomposition (Zhou et al., 6 Aug 2025). The multimodal Ref-Thinker produces a tagged “think–answer” chain with a fine-grained object description TfT_f and a simplified category TsT_s; Grounding-DINO consumes the selected description as an explicit prompt to predict boxes; and SAM2 uses those boxes to generate masks without any pixel-level fine-tuning of the segmentation model. The overall task is factorized as

Think(A,V,R,P)T,Ground(Tf/Ts,V)B,Segment(B,V)M.Think(A, V, R, P) \to T,\quad Ground(T_f/T_s, V) \to B,\quad Segment(B, V) \to M.

The paper reports state-of-the-art results on Ref-AVSBench and the newly introduced R2R^2-AVSBench, with TGS-Agent exceeding SAM2-LOVE by +7.2+7.2 JF on the Seen split and %Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,0 JF on the Unseen split, while achieving %Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,1 on the Null split (Zhou et al., 6 Aug 2025).

A similar reference-design usage appears in recommendation. "AgentRecBench" does not introduce a formal system named RefAgent; rather, the provided synthesis constructs a reference agent from the paper’s modular framework for agentic recommendation (Shang et al., 26 May 2025). That framework models the environment as %Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,2, lets an agent select actions from %Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,3, and emphasizes a planner/controller, short- and long-term memory, structured and textual tool use, and reflection over ranking outcomes. The benchmark evaluates classic, evolving-interest, and cold-start recommendation scenarios under an HR@%Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,4 protocol over 20 candidates. The strongest agentic systems substantially outperformed classical baselines in several Amazon and Goodreads settings; for example, under Qwen-72B in the classic Amazon scenario, Baseline666 reached 69.0 while BaseAgent reached 39.0 (Shang et al., 26 May 2025).

The web-navigation paper "Reflection-Based Memory For Web navigation Agents" extends the same motif through persistent reflection memory rather than architectural role separation (Azam et al., 2 Jun 2025). ReAP stores compact reflections %Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,5 keyed by task text and retrieved by cosine similarity in embedding space, then conditions the planning policy on the retrieved reflections:

%Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,6

It improved success rate by 11 points overall on unseen but similar tasks and by 28–29 points on previously failed tasks, while also reducing steps, tokens, and time-to-complete (Azam et al., 2 Jun 2025). Taken together, these works show that “RefAgent” is often associated with explicit intermediate reasoning, externalized memory, and tool-mediated refinement, even when the formal system name differs.

Several contemporaneous agent frameworks are regularly confusable with RefAgent because of their names, but their mechanisms are domain-specific and should be distinguished precisely.

ReAgent for multi-hop QA introduces reversible multi-agent reasoning with explicit backtracking, satisfiability-based conflict detection, local correction, and global rollback (Zhao et al., 10 Mar 2025). Its global state is

%Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,7

and conflicts are detected when %Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,8 fails. The framework defines

%Δsmells=SbeforeSafterSbefore×100%,\%\Delta_{\text{smells}} = \frac{S_{\text{before}} - S_{\text{after}}}{S_{\text{before}}} \times 100\%,9

and a global rollback operator QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.0. On HotpotQA, 2WikiMultiHopQA, and MuSiQue, ReAgent reported an average improvement of about 6% against baseline models, with a QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.1 EM and QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.2 F1 advantage over GPT-4o in the knowledge-augmented setting (Zhao et al., 10 Mar 2025).

ReAgent-V is a reward-driven framework for video understanding rather than refactoring or retrieval-centric reasoning (Zhou et al., 2 Jun 2025). Its signature components are entropy-calibrated frame selection, real-time reward generation during inference, and multi-perspective reflection with conservative, neutral, and aggressive revision policies. The frame selector computes an Entropy-Calibrated Relevance Score,

QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.3

and reflection candidates are compared through confidence scores QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.4. Across 12 datasets, the paper reports improvements of up to 6.9% for video understanding, 2.1% for video reasoning enhancement, and 9.8% for vision-language-action alignment (Zhou et al., 2 Jun 2025).

Refer-Agent addresses referring video object segmentation through alternating reasoning and reflection (Jiang et al., 3 Feb 2026). Its pipeline is Frame Selection QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.5 Intent Analysis QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.6 Object Grounding QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.7 Mask Generation, supplemented by a two-stage Chain-of-Reflection composed of Existence Reflection and Consistency Reflection. The system is fully zero-shot, uses CLIP for coarse frame scoring, Ovis2.5-9B as the default MLLM, and SAM2 for mask propagation. It reported J&F scores of 71.3 on Ref-YouTube-VOS, 54.7 on MeViS, 69.8 on ReasonVOS, 33.4 on GroundMoRe, and 61.3 overall on ReVOS, while exceeding SFT-based methods by QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.8 J&F on ReasonVOS and QI(Aq)=Aq(p)Aq(p)Aq(p)×100.QI(A_q) = \frac{A_q(p') - A_q(p)}{|A_q(p)|} \times 100.9 J&F on ReVOS (Jiang et al., 3 Feb 2026).

A different ReAgent appears in security as a defense against backdoor attacks in LLM-based agents (Changjiang et al., 10 Jun 2025). There the method checks consistency between user instruction, thought trajectory, and executed actions at both planning and execution levels. It was evaluated on OS, database, and WebShop tasks and reduced attack success rate by up to 90% in database operation tasks (Changjiang et al., 10 Jun 2025). The overlap in name is purely orthographic; the threat model, evaluation, and mechanisms are unrelated to software refactoring.

7. Limitations, misconceptions, and likely trajectories

A common misconception is that RefAgent names a single, standardized architecture across arXiv. The evidence does not support that view. The formal RefAgent system is the software-refactoring framework (Oueslati et al., 5 Nov 2025); other papers either use different names altogether (Zhao et al., 10 Mar 2025, Zhou et al., 2 Jun 2025, Jiang et al., 3 Feb 2026), or employ “RefAgent” only as a descriptive or constructed shorthand (Zhou et al., 6 Aug 2025, Shang et al., 26 May 2025).

For the refactoring framework specifically, the stated limitations are concrete. It was evaluated on Java and Apache projects, so extension to other languages and ecosystems would require adapting tools and refactoring taxonomies. Runtime overhead is nontrivial because compilation and testing loops can each run for up to 20 iterations. Tool-chain dependencies such as Maven, EvoSuite, DesigniteJava, and jdeps introduce variability, and even combined developer and EvoSuite tests may miss subtle behavioral regressions not covered by the available test oracles (Oueslati et al., 5 Nov 2025). The empirical study of real-world agentic refactoring reinforces the need for stronger structural guidance and smell-aware validation, since agent refactorings in practice can over-index on annotation edits and, in at least one case, significantly increase smell counts (Ottenhof et al., 28 Jan 2026).

Across neighboring domains, the recurrent constraints are similarly specific: retrieval quality limits reversible QA even with backtracking (Zhao et al., 10 Mar 2025); grounding rare categories and complex audio overlap remain difficult in audio-visual segmentation (Zhou et al., 6 Aug 2025); weaker zero-shot MLLMs and longer reflection loops trade accuracy for latency in RVOS (Jiang et al., 3 Feb 2026); stale or low-quality reflections can cause negative transfer in web navigation memory systems (Azam et al., 2 Jun 2025); and subtle malicious preferences are harder to flag in backdoor defense than overt plan–action contradictions (Changjiang et al., 10 Jun 2025). This suggests that the durable core of the RefAgent family is not any one module, but a control philosophy: expose intermediate structure, validate it against external evidence, and revise rather than commit irrevocably.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to RefAgent.