Multi-level memory helps coding agents reuse scientific programming lessons
MUSE: Multi-Level Memory with Selective Runtime Injection for Scientific Coding Agents
Machine LearningArtificial Intelligence
Summary
Scientific coding often benefits from looking at past experiences to write better programs, but focusing only on high-level tasks misses important details that come up during actual coding. The authors created MUSE, a system that stores memory at global, approach, and detailed implementation levels to help coding agents recall relevant past lessons during different stages. MUSE also uses a smart selector to decide when to share helpful advice while coding. Their tests on various scientific coding problems show that MUSE performs better than other methods, and its memory can transfer across similar tasks to save time and improve coding.
What this means in practice
- •For software engineering teams: Improve automated code generation tools by reusing past programming experience at multiple detail levels for scientific software projects.
- •For high performance computing engineers: Enhance kernel optimization workflows by selectively injecting relevant coding advice during runtime from a structured memory.
Authors
Haoran Jin, Defu Lian, Xiting Wang, Hong Xie
Abstract
Historical experience can guide scientific coding at multiple levels, but task-level retrieval may miss implementation lessons that become relevant during execution. We introduce MUSE, a memory management framework combining multi-level memory with selective runtime injection for scientific coding agents. MUSE builds global, approach-level, and implementation-level memory from historical trajectories. At initialization, the agent receives global memory and problem-matched approach-level memory. During execution, current interactions are used to retrieve implementation-level memory. An LLM gate selects relevant experience and generates specific review advice, or skips injection. Across four benchmarks spanning numerical problem solving, kernel optimization, and scientific software repair, MUSE outperforms retrieval and memory baselines on all evaluation metrics. Ablations support the multi-level design and gated injection, while transfer experiments show that memory remains useful across kernel benchmarks. These results show that multi-level memory and selective runtime injection enable effective reuse of experience in scientific coding. Code is available at https://github.com/hr-jin/MUSE.