MOSAIC: Multi-agent Orchestration for Task-Intelligent Scientific Coding
Siddeshwar Raghavan, Tanwi Mallick
TL;DR
MOSAIC introduces a training-free, LLM-agnostic multi-agent framework for scientific code generation that decomposes complex problems into chained subproblems using four specialized agents (Self-Reflection, Rationale, Coding, Debugger) and a teacher-guided knowledge-distillation workflow. A Consolidated Context Window and domain-specific memories mitigate hallucinations and cross-domain interference, enabling robust, executable code without validation I/O. Across SciCode and general coding benchmarks, MOSAIC achieves higher problem-solving accuracy and better precision than strong baselines, with ablations showing the value of orchestrating distinct expert roles. This work offers a scalable, interpretable approach to complex scientific programming, with potential for heterogeneous backbones and reinforcement learning from execution feedback to further enhance performance and reliability.
Abstract
We present MOSAIC, a multi-agent Large Language Model (LLM) framework for solving challenging scientific coding tasks. Unlike general-purpose coding, scientific workflows require algorithms that are rigorous, interconnected with deep domain knowledge, and incorporate domain-specific reasoning, as well as algorithm iteration without requiring I/O test cases. Many scientific problems also require a sequence of subproblems to be solved, leading to the final desired result. MOSAIC is designed as a training-free framework with specially designed agents to self-reflect, create the rationale, code, and debug within a student-teacher paradigm to address the challenges of scientific code generation. This design facilitates stepwise problem decomposition, targeted error correction, and, when combined with our Consolidated Context Window (CCW), mitigates LLM hallucinations when solving complex scientific tasks involving chained subproblems. We evaluate MOSAIC on scientific coding benchmarks and demonstrate that our specialized agentic framework outperforms existing approaches in terms of accuracy, robustness, and interpretability.
