As organizations modernize their software infrastructure, they frequently face the daunting task of migrating massive codebases from legacy languages (like C or Java) to modern alternatives (like Rust or Python). This process, known as code translation, carries significant risk. Ensuring that the newly translated code behaves exactly like the original is a critical, yet notoriously difficult, challenge.
Existing automated validation and repair tools suffer from three major bottlenecks:
- High Engineering Overhead: Most tools are hard-coded for specific language pairs. Supporting a new pair often requires thousands of lines of custom code to handle language interoperability.
- Inadequate Test Suites: Validation typically relies on existing unit tests. If the original tests are incomplete, tools may falsely claim a translation is perfectly equivalent when it actually harbors subtle bugs.
- Ineffective Repair: When bugs are detected, existing tools struggle to fix them because they lack a holistic understanding of complex repository-level dependencies.
To bridge this gap, researchers have developed MatchFixAgent, a language-agnostic, multi-agent framework that leverages Large Language Models (LLMs) to autonomously validate and repair code translations.
How MatchFixAgent Works
MatchFixAgent abandons rigid, rule-based systems in favor of a flexible, agentic architecture. By decomposing the complex problem of semantic analysis into specialized sub-tasks, the framework ensures thorough and consistent evaluation.
- Multi-Agent Semantic Analyzer: Rather than asking an LLM to evaluate an entire function at once, the system deploys six specialized "sub-analyzers." These agents independently evaluate Control Flow, Data Flow, I/O Mapping, Library APIs, Exceptions/Errors, and Specifications.
- Hybrid Structural Analysis: To optimize costs and speed, the system uses Tree-Sitter—a language-agnostic parser—to compute similarity scores for Control Flow and Data Flow graphs. If the code structures are identical, it safely bypasses the LLM call.
- Test Generator & Repair Agent: Using Claude Code, this agent takes the semantic reports and writes executable tests in both languages to confirm suspected inequivalences. If a test fails, the agent attempts to patch the translated code.
- Verdict Agent: A final agent synthesizes all gathered evidence to deliver a definitive "Equivalent" or "Not Equivalent" verdict.
Evaluation and Key Results
The researchers evaluated MatchFixAgent on a massive benchmark of 2,219 source-translation function pairs drawn from 24 real-world projects (totaling over 900,000 lines of code). The dataset spanned six programming languages (Java, Python, Go, Rust, C, and JavaScript) and included translations generated by four state-of-the-art tools: ALPHATRANS, OXIDIZER, SKEL, and RUSTREPOTRANS.
The results demonstrate a massive leap in performance over existing methods:
- Superior Coverage: MatchFixAgent successfully produced a verdict for 99.2% of translation pairs, compared to just 71.6% for prior tools (which often crashed on complex dependencies).
- Higher Accuracy: It agreed with prior work on 72.8% of cases. In instances where MatchFixAgent disagreed with prior tools, manual investigation revealed that MatchFixAgent was correct 60.7% of the time.
- Powerful Repair: The framework successfully repaired 50.6% of inequivalent translations, nearly tripling the 18.5% repair rate of previous state-of-the-art techniques.
- High Efficiency: The entire system is remarkably lightweight, built with only 1,650 lines of code. Adding support for a new language requires a mere ~280 lines of code. On average, validating and repairing a function takes about 5 minutes and costs just $1.22.
Key Insights
The success of MatchFixAgent highlights several important takeaways for AI-assisted software engineering. First, decomposition beats brute force. LLMs are significantly more reliable when forced to analyze specific dimensions of code (like exception handling) rather than reasoning about a whole function simultaneously.
Second, language agnosticism is highly practical. Combining Tree-Sitter with LLM reasoning drastically reduces the engineering burden of supporting new languages. Finally, closing the loop with execution is vital. By generating and running actual tests to verify its findings, MatchFixAgent effectively mitigates the risk of LLM hallucinations.
Limitations and Future Directions
Despite its impressive performance, MatchFixAgent has a few limitations. LLMs still occasionally hallucinate (noted in 36 cases during the study). Additionally, the agent sometimes generates "infeasible inputs"—tests that prove a difference in behavior but require impossible real-world states, such as manually setting a private variable. Furthermore, in languages like Rust, translations are often refactored to be more "idiomatic" (e.g., returning a reference instead of a copy). The tool sometimes flags these as bugs, even though human developers would consider them improvements.
Future work will explore building full call graphs to better handle complex dependencies across repositories and investigate the use of smaller, more cost-effective LLMs for trivial code segments.
Summary updated