RepoTransAgent: Multi-Agent LLM Framework for Repository-Aware Code Translation

📅 2025-08-25
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Existing code translation methods suffer from three key limitations in real-world codebases: weak contextual understanding, inflexible prompt design, and insufficient error correction capability. To address these challenges, this paper proposes a repository-level multi-agent code translation framework that decomposes the task into three synergistic submodules: context-aware retrieval, dynamic prompt construction, and iterative refinement. We introduce a novel reflection-based error correction mechanism that integrates retrieval-augmented generation (RAG), adaptive prompt engineering, and multi-agent collaboration to enable semantic-aware end-to-end translation. Empirical evaluation across six open-source projects for Java-to-C# translation demonstrates that our approach achieves a compilation success rate of 55.34% and a test pass rate of 45.84%, significantly outperforming state-of-the-art methods.

Technology Category

Application Category

📝 Abstract
Repository-aware code translation is critical for modernizing legacy systems, enhancing maintainability, and enabling interoperability across diverse programming languages. While recent advances in large language models (LLMs) have improved code translation quality, existing approaches face significant challenges in practical scenarios: insufficient contextual understanding, inflexible prompt designs, and inadequate error correction mechanisms. These limitations severely hinder accurate and efficient translation of complex, real-world code repositories. To address these challenges, we propose RepoTransAgent, a novel multi-agent LLM framework for repository-aware code translation. RepoTransAgent systematically decomposes the translation process into specialized subtasks-context retrieval, dynamic prompt construction, and iterative code refinement-each handled by dedicated agents. Our approach leverages retrieval-augmented generation (RAG) for contextual information gathering, employs adaptive prompts tailored to varying repository scenarios, and introduces a reflection-based mechanism for systematic error correction. We evaluate RepoTransAgent on hundreds of Java-C# translation pairs from six popular open-source projects. Experimental results demonstrate that RepoTransAgent significantly outperforms state-of-the-art baselines in both compile and pass rates. Specifically, RepoTransAgent achieves up to 55.34% compile rate and 45.84% pass rate. Comprehensive analysis confirms the robustness and generalizability of RepoTransAgent across different LLMs, establishing its effectiveness for real-world repository-aware code translation.
Problem

Research questions and friction points this paper is trying to address.

Addressing insufficient contextual understanding in code translation
Overcoming inflexible prompt designs for repository scenarios
Improving error correction mechanisms for accurate translation
Innovation

Methods, ideas, or system contributions that make the work stand out.

Multi-agent LLM framework for repository-aware translation
RAG for contextual information gathering
Reflection-based mechanism for error correction
🔎 Similar Papers
No similar papers found.
Z
Ziqi Guan
Zhejiang University, Hangzhou, China
X
Xin Yin
Zhejiang University, Hangzhou, China
Z
Zhiyuan Peng
Shanghai Jiao Tong University, Shanghai, China
Chao Ni
Chao Ni
Zhejiang University
AI4SESoftware AnalyticsSoftware Maintenance