In the world of multi-agent systems (MAS), we usually play the role of the micromanager. We define the roles, draw the flowcharts, and tell the agents exactly who talks to whom. But as tasks get more complex, these rigid, "one-size-fits-all" structures become a bottleneck.
A new paper from the National University of Singapore introduces DynaFlow, a framework that moves away from predefined graphs. Instead, it treats multi-agent orchestration as a free-form programming task. The "Main Agent" doesn't just solve the problem; it writes a JavaScript program to coordinate a team of sub-agents specifically for the question at hand.
TL;DR
DynaFlow enables a "Main Agent" to dynamically synthesize executable JavaScript workflows to coordinate sub-agents on the fly. By training the orchestrator to decide when and how to collaborate, the system achieves an 88.08% accuracy across diverse reasoning benchmarks, outperforming fixed-structure baselines by over 10 percentage points.
What Problem Does This Paper Address?
Most current multi-agent frameworks rely on fixed collaboration patterns. While effective for specific domains, these structures are brittle. A simple query might not need a five-agent debate (wasting time and tokens), while a complex multi-hop retrieval task might fail because the predefined "Researcher" role wasn't allowed to talk to the "Verifier" in a specific way.
The authors argue for Free Orchestration: the ability for an agent to:
- Decide if collaboration is even necessary.
- Construct a task-specific workflow (sequential, parallel, or hybrid).
- Manage the "data flow"—ensuring the right information reaches the right agent at the right time.
Methods
The core of DynaFlow is integrating workflow synthesis directly into the agent's action space. When faced with a query, the Main Agent can choose to answer directly, call a standard tool, or generate a JavaScript program.
The JavaScript Action Space
The Main Agent uses a set of primitives—agent(), parallel(), pipeline(), and phase()—to write its workflow. This allows for complex logic, such as running three different solvers in parallel and then passing their outputs to a single verifier for a "majority vote" or a "critique."
Two-Stage Learning
The authors decouple the "orchestrator" from the "executors." They keep the sub-agents frozen and only train the Main Agent using a two-stage Supervised Fine-Tuning (SFT) process:
- Trajectory Distillation: The model learns from high-quality trajectories generated by a powerful teacher model (GLM-5.3 Max).
- High-Quality Data Selection: An LLM judge filters the training data to remove "defective" workflows. It looks for issues like premise injection (the orchestrator giving the answer away in the prompt), verification bias, and information-flow defects (where data gets lost between steps).
Datasets
The system was evaluated on 688 questions across six challenging benchmarks:
- AIME (2024, 2025, 2026): High-level competition mathematics.
- PolyMATH: Multilingual mathematical reasoning.
- GPQA-Diamond: Graduate-level science questions (Biology, Physics, Chemistry).
- HotpotQA: Multi-hop question answering requiring web search.
Key Insights and Ideas
- Workflows are a liability without training: One of the most striking findings is that an untrained "Base" model actually performs worse when forced to use a multi-agent workflow than when answering directly (see Figure 3). Orchestration is a distinct skill that must be learned.
- The "Lazy" Orchestrator is Efficient: In "Dynamic" mode, DynaFlow learns to solve 47% of questions directly without invoking a workflow. This reduces the average number of sub-agent calls by 41% while maintaining nearly the same accuracy as the "Forced" workflow mode.
- Information Flow is the Secret Sauce: The refinement in Stage 2 of training focused heavily on how data moves. As shown in Figure 5, trained models moved from "Single agent" or "Serial" structures to "Hybrid" ones, where "Consumed" output reuse (actually using upstream data to refine a result) became the norm.
Key Results
- State-of-the-Art Accuracy: DynaFlow achieved 88.08% overall accuracy in Forced mode, a massive jump from the 75.9% achieved by the base Qwen3.5-27B model.
- Math Mastery: It solved 100% of the AIME questions across all three years tested.
- Better Design: Qualitative analysis (Figure 4) shows that Stage 2 training significantly reduced "major defects" in workflow design, particularly in logical continuity and information flow.
Limitations and Future Work
While DynaFlow is a significant step forward, the authors note a few areas for growth:
- First-Turn Focus: The current training focuses on the initial workflow design. If a workflow fails halfway through, the agent's ability to "live-debug" and revise the program is an area for future multi-turn trajectory research.
- Sub-agent Capabilities: Since sub-agents were kept frozen, the system is still limited by the underlying reasoning power of the executors. Jointly training the orchestrator and the executors for better "information handshakes" could yield even higher gains.
- Coding Dependency: This approach requires a Main Agent with strong coding capabilities to generate valid JavaScript, which might limit its use with smaller, less capable models.
Summary updated