Multi-Agent Strategies for Bridging Programming Language Gaps in Code Generation
Real-world software systems are inherently multilingual, but current large language models are not equally consistent across programming languages. This mismatch limits code generation usefulness, especially for underrepresented languages. Existing approaches improve code generation through fine-tuning, multi-agent reasoning, or translation, but remain language-specific, assume existing source code, or rely on per-language test suites. We introduce XL-CoGen, a three-stage multilingual code-generation pipeline that starts from a natural-language specification and a shared test list to generate correct implementations across multiple target languages. XL-CoGen first validates direct generation by constructing and correcting the test harness; when it fails, it transfers through empirically selected intermediate languages and translates validated solutions; it then repairs the best candidate through diagnosis and minimal patching. This design requires neither target-language training nor language-specific test suites. Across two benchmarks and multiple LLMs, XL-CoGen consistently improves over direct generation, with the largest gains on low-performing languages. In our Rust fine-tuning case study, XL-CoGen outperforms the best fine-tuned baseline by 22 percentage points and improves challenging languages by up to 33 points on multilingual benchmarks. Ablation results show that transfer and repair are complementary: repair suffices on easier tasks, whereas transfer becomes more important as difficulty increases, especially for weak target languages.