DynaFlow: Learning Free-Form Multi-Agent Orchestration

Ruhao Liu, Qi Li, Shizun Wang, Xinchao Wang

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:

  1. Decide if collaboration is even necessary.
  2. Construct a task-specific workflow (sequential, parallel, or hybrid).
  3. 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.

Figure 2: Overview of DynaFlow. (1) Two-stage SFT trains only the Main Agent on first-turn reasoning r and workflow action a1, using distilled demonstrations followed by a curated subset. (2) It chooses to answer directly, call a tool, or generate a JavaScript workflow. (3) Frozen sub-agents collaborate within the workflow according to the Main Agent’s program. (4) Outputs and execution traces update the history for subsequent decisions.

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:

  1. Trajectory Distillation: The model learns from high-quality trajectories generated by a powerful teacher model (GLM-5.3 Max).
  2. 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.
Figure 1: Overall accuracy versus collaboration size. Accuracy versus the mean number of agent roles per question on 688 questions (Qwen3.5-27B). In Forced mode, DynaFlow improves accuracy from Base’s 75.9% to 88.1%. Dynamic achieves 87.9% with 3.44 agent roles per question on average, while answering 47% of questions without workflows.

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.
Accuracy gains across different benchmarks after training.

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

Abstract

Multi-agent systems often rely on predefined collaboration structures, limiting their ability to adapt to diverse task requirements. We introduce DynaFlow, a framework that integrates free-form executable workflow synthesis into the action space of the main agent. The agent decides when collaboration is needed and generates task-specific programs that coordinate sub-agents through sequential or parallel execution, structured information exchange, and verification. Execution results and traces inform subsequent actions, enabling the agent to adapt collaboration as reasoning progresses. We train only the main agent through supervised fine-tuning on distilled trajectories, followed by refinement on examples filtered for unsupported premises, biased verification, and information-flow defects. All sub-agents remain fixed, separating orchestration learning from executor capability improvement. Across six benchmarks spanning mathematical reasoning, scientific question answering, and multi-hop retrieval, DynaFlow achieves 88.08% overall accuracy in Forced mode, outperforming the strongest evaluated baseline by 10.90 percentage points with the same Qwen3.5-27B backbone. Workflow analysis finds more explicit use, verification, and refinement of upstream outputs after training, highlighting cross-stage information flow as a key dimension of multi-agent orchestration.
BibTeX
@misc{liu2026dynaflow,
  author = {Ruhao Liu and Qi Li and Shizun Wang and Xinchao Wang},
  title = {{DynaFlow: Learning Free-Form Multi-Agent Orchestration}},
  year = {2026},
  eprint = {2610.34467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.34467},
}
Figure