MOSAIC: Modular Orchestration for Structured Agentic Intelligence and Composition

Yifan Bao, Xinyu Xi, Xinyu Liu, Wen Ge, Lei Jiang, Kevin Zhang, Raad Khraishi, Yihao Ang, Anthony K. H. Tung, Lukasz Szpruch, Hao NiarXiv 2026

TL;DR

MOSAIC is a novel agentic framework that automates data science by treating model building as a structured, memory-grounded workflow construction problem rather than unconstrained code generation. By introducing an intermediate "blueprint" layer with strict interface constraints and optimizing code edits via a failure-aware offline reinforcement learning policy, MOSAIC consistently outperforms traditional AutoML and LLM baselines on complex financial time-series tasks while maintaining a 100% execution success rate.

What Problem Does This Paper Address?

Automating data science is notoriously difficult because modeling decisions are deeply interconnected—a change in data normalization can break an architecture, which in turn requires a different training schedule or loss function.

Traditional AutoML systems (like AutoGluon or Optuna) handle this by searching within rigid, predefined pipelines and hyperparameter spaces, missing out on novel or customized architectures. On the flip side, recent Large Language Model (LLM) agents offer incredible flexibility by writing custom code on the fly. However, these agents typically lack structure; they write free-form code that frequently suffers from syntax errors, shape mismatches, or optimization failures, making their decisions hard to verify and reuse.

MOSAIC tackles this gap specifically within the demanding domain of financial time-series forecasting and generation, where models must not only be accurate but also respect strict statistical distributions and downstream financial risk constraints.

Methods

MOSAIC introduces a staged, context-grounded search pipeline that splits the modeling process into distinct, manageable phases:

Figure 1: Overview of the MOSAIC pipeline.
  1. Semantic-Aware EDA: The system uses a Vision-Language Model (VLM) alongside text processing to analyze data schemas, statistics, and visual patterns (like volatility clustering), embedding these insights into a structured task profile.
  2. Case Retrieval: MOSAIC queries a "Case Bank" of prior task-solution pairs to find successful modeling strategies used for similar datasets.
  3. Repository-Grounded Model Generation: Instead of letting an LLM synthesize code from scratch, MOSAIC extracts reusable modules (encoders, embeddings, heads) from existing code repositories. It then constructs a Blueprint—an intermediate representation that defines module selection, composition order, and strict dimensional "shape contracts." The LLM merely executes this blueprint to generate candidate code.
  4. RL-Guided Long-Horizon Refinement: Model optimization is a long-horizon process where greedy "edit-and-test" loops often fail. MOSAIC trains an offline Reinforcement Learning (RL) policy using Implicit Q-Learning (IQL) to select high-level refinement strategies (e.g., adjusting regularizations or schedules), which a frozen LLM then implements.

To handle the high volume of broken code generated during exploration, MOSAIC utilizes a failure-aware trajectory branching mechanism. If an edit causes a hard failure (crash) or soft failure (performance drop), the system logs the failure as negative supervision, updates an invalid-action mask, and rolls back to the last valid checkpoint.

Datasets

The framework was evaluated on three distinct financial time-series datasets:

  • Crypto: Hourly closing prices for 20 cryptocurrency trading pairs against USDT in 2024.
  • LOB (Limit Order Book): High-frequency limit order book data from NASDAQ, featuring millisecond-resolution event streams. This represents a challenging, low-data regime.
  • Stock: Daily closing prices for 10 major U.S. equities from 2020 to 2024.

To train the offline RL policy without information leakage, the authors also constructed a separate Dataset Bank ($B_{data}$) containing 60 U.S. large-cap equities, 16 foreign exchange pairs, 17 commodity futures, 22 distinct cryptocurrencies, and 10 U.S. Treasury maturities.

Key Insights and Ideas

  • The Blueprint Layer is Crucial: Separating architectural reasoning (the blueprint) from code synthesis prevents the LLM from hallucinating invalid configurations. Enforcing shape contracts ensures that combined modules actually fit together mathematically.
  • Failure is Useful Supervision: Rather than simply discarding broken code or failed training runs, MOSAIC uses trajectory branching to turn bugs into explicit negative constraints (invalid-action masking), teaching the agent what not to do in specific diagnostic states.
  • Look Beyond the Next Step: Greedy optimization loops miss out on compound improvements (e.g., adding normalization before changing a learning rate). The offline RL policy learns to value actions that pave the way for long-term performance gains.

Key Results

MOSAIC consistently dominated both traditional AutoML and advanced agentic baselines across all datasets and backbones (including GPT-4o, Claude Opus, and Nova Pro).

Figure 4: Radar charts for ranking.
  • Forecasting Accuracy: Compared to the leading agentic baseline (TS-Agent), MOSAIC reduced Root Mean Squared Error (RMSE) by 8% on LOB, 5% on Crypto, and 3% on Stock. Compared to AutoGluon, RMSE reductions reached up to 33% on the LOB dataset.
  • Financial Risk Mitigation: On the Crypto dataset, MOSAIC achieved a massive 21%+ reduction in $\Delta$Sharpe relative to TS-Agent, proving its sensitivity to downstream financial risk and tail behavior.
  • Execution Reliability: While baseline agents suffered from code fragility—with success rates dropping as low as 20% on weaker LLM backbones—MOSAIC maintained a 100% system-level success rate across all dataset-backbone pairs due to its robust verification and rollback guardrails.

Limitations and Future Work

Despite its strong performance, the authors note several limitations:

  1. Knowledge Bank Dependency: MOSAIC’s performance ceiling is inherently bound to the quality and diversity of its Case Bank and Code Base.
  2. Computational Cost: The iterative "execute-verify-refine" loop requires repeatedly running code and training models, which can be computationally expensive.
  3. Lack of Formal Guarantees: While shape contracts help, the framework still lacks rigorous, formal type-checking guarantees to verify the functional compatibility of synthesized modules before execution.

Future work aims to explore adaptive methods for RL-driven retrieval and expanding MOSAIC to broader, non-financial data science domains.

Summary updated

BibTeX
@misc{bao2026mosaic,
  author = {Yifan Bao and Xinyu Xi and Xinyu Liu and Wen Ge and Lei Jiang and Kevin Zhang and Raad Khraishi and Yihao Ang and Anthony K. H. Tung and Lukasz Szpruch and Hao Ni},
  title = {{MOSAIC: Modular Orchestration for Structured Agentic Intelligence and Composition}},
  year = {2026},
  eprint = {2606.00708},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.00708},
}
Figure