LegoSR: A Unified Framework for Self-Improving Agent-Guided Scientific Discovery
Discovering equations from data provides governing laws, constitutive relations and closure models for scientific understanding and prediction. Yet a method that succeeds on one system may fail on another or on noisy data, so discovery depends on expert trial and error. Unsuccessful searches can still reveal useful parts of an equation, but these clues must be recognized and combined. We present LegoSR, a unified framework for agent-guided equation discovery built on composable discovery and cumulative experience. Seven complementary equation discovery methods and shared computational modules form reusable building blocks, connected through a common equation representation. Researchers can launch discovery with one command and guide it with partially known equations. LegoSR Agent selects methods, revises searches using feedback and combines partial findings into new hypotheses. Its Experience Library consolidates graded outcomes into lessons that guide later tasks across equation families. Evaluation covers 134 algebraic regression problems, 40 ordinary differential equation targets and 25 partial differential equation problems at several noise levels, together with three case studies. On noisy PDEs, LegoSR Agent recovers more equations than seven expert-tuned methods combined and stays close to them on ODEs. It also exceeds a generic agent with the same model, tools and budget by up to 28 percentage points, with 63-73% shorter median wall-clock time on PDE problems.