DynaFlow
EN中文

On this page

DYNAMIC MULTI-AGENT WORKFLOWS

DynaFlow

Learning Free-Form
Multi-Agent Orchestration

Ruhao Liu, Qi Li, Shizun Wang, Xinchao Wang

Task-Specific Collaboration by Design.
Generate, execute, and refine multi-agent workflows as code.

DynaFlow overview in four panels: trajectory learning with two-stage SFT, the Main Agent choosing an answer, tool call or JavaScript workflow, frozen sub-agents executing research, reasoning and verification, and results feeding back; Forced accuracy rises from 75.87 (Base) to 85.47 (Stage 1) and 88.08 (DynaFlow).
Overview of DynaFlow. Only the Main Agent is trained. It answers directly, calls a tool, or writes a JavaScript workflow; frozen sub-agents execute it, and the outputs and trace inform the next decision.
88.1%Overall accuracy · 688 questions
+10.9Points over the strongest baseline
47%Answered without a workflow, −0.14 pts

Qwen3.5-27B throughout · six benchmarks · Explore the results ↓

INTRODUCTION

Collaboration should fit the task.

Different tasks need different collaboration: some are best answered directly, others need parallel exploration or ordered reasoning and verification. DynaFlow lets the Main Agent design its own collaboration, deciding when a workflow is worth it and writing a task-specific program that defines roles, dependencies, information exchange, and checks.

METHOD

A workflow is an action.

The Main Agent writes, runs, and revises a program for each collaboration.

01

Choose & synthesize

Answer directly, call a tool, or write a JavaScript workflow.

02

Execute & exchange

Run sub-agents in sequence or in parallel and pass outputs to the agents that need them.

03

Observe & adapt

Read the outputs and trace, then answer or launch a follow-up workflow.

04

Train the orchestrator

Two-stage SFT trains only the Main Agent; sub-agents stay frozen.

CASE STUDIES

Inside the workflows.

Base and DynaFlow workflows on the same question, with the same frozen sub-agents.

MATHEMATICS

Three methods. One independent check.

Task. Count palindromes with nonzero digits whose digit sum is 13.

Base uses one palindrome solver; DynaFlow combines three parallel counting methods and a verifier.
AIME 2026: palindrome counting. One solver versus three complementary computations feeding a verifier.

Tap the figure to enlarge.

Outcome

Base returns 59 after an arithmetic error. DynaFlow’s three solvers and verifier all obtain the correct 62.

SCIENCE

Keep the evidence alongside the objections.

Task. Identify the products of reactions A and B and choose the matching answer option.

Four chemistry researchers, two checks and a decision agent, compared with two sequential Base calls.
GPQA-Diamond: reaction-product identification. Research evidence and verification results both reach the decision agent.

Tap the figure to enlarge.

Outcome

Base runs two unconnected analyses. DynaFlow’s checks challenge the first candidates, and the decision agent weighs research and objections together.

MULTI-HOP RETRIEVAL

Pass entities and sources to the next search.

Task. Identify the person associated with an investment description, then retrieve the year requested by the question.

Three retrieval routes, candidate ranking, two resolution calls and two checks, with invalid outputs marked.
HotpotQA: person identification and year retrieval. Candidate identification feeds targeted resolution; starred calls returned no valid output.

Tap the figure to enlarge.

Outcome

Base searches for firms and founding years. DynaFlow identifies candidate people first, then retrieves the year for each.

GEOMETRY

Connect optimization to independent audits.

Task. Minimize the sum of distances to five pentagon vertices and recover m + n + p from the minimum m + n√p.

Geometry reconstruction, parallel optimization, expression fitting, two audits and an unexecuted repair branch.
AIME 2025: geometric optimization. Construction, parallel optimization, fitting, and audits linked by intermediate outputs.

Tap the figure to enlarge.

Outcome

One optimizer fails and is filtered out; both audits confirm the fitted answer, so the repair branch never runs.

EXPERIMENTAL RESULTS

Best overall accuracy in both modes.

Same Qwen3.5-27B backbone, frozen sub-agents, tools, and runtime throughout.

+10.9vs. Self-Refine, the strongest baseline
+11.6vs. AFlow
+12.2vs. the same Main Agent before training

Swipe the table sideways to see all benchmarks.

Main results. Overall is micro-averaged over all 688 questions; runs without a valid final answer count as incorrect.
MethodAIME ’24
30
AIME ’25
30
AIME ’26
30
PolyMATH
200
GPQA-D
198
HotpotQA
200
Overall
688
Single-agent baselines
CoT96.6793.3386.6783.0085.3546.5074.27
CoT-SC90.0093.3396.6784.5085.8650.5076.16
Self-Refine96.6793.3393.3387.5088.3848.0077.18
Automated multi-agent baseline
AFlow93.3396.67100.0086.0087.3747.0076.45
Untrained Main Agent
Base Direct93.3393.3393.3374.0083.3347.5071.51
Base + Web search83.3373.3373.3366.0079.8077.5074.71
Base Dynamic63.3363.3373.3364.0077.7853.0065.12
Base Forced76.6770.0070.0070.0077.7881.5075.87
Trained Main Agent (ours)
DynaFlow Direct93.3390.0090.0087.0086.8751.5077.18
DynaFlow Dynamic93.33100.0096.6791.5083.8484.5087.94
DynaFlow Forced100.00100.00100.0090.5084.8583.5088.08

Overall is micro-averaged over 688 questions. Only Base + Web search and the workflow settings have retrieval, so HotpotQA is not a like-for-like comparison with single-agent baselines.

Line chart of overall accuracy against agent roles per question. DynaFlow rises from 77.2% (Direct, 1 role) to 87.9% (Dynamic, 3.44 roles) and 88.1% (Forced, about 5.2 roles); Base drops from 71.5% Direct to 65.1% Dynamic and reaches 75.9% Forced; baselines sit between 74% and 77%.
Overall accuracy versus collaboration size. More agents alone do not help. DynaFlow, Dynamic reaches 87.9% with 3.44 roles per question and answers 47% of questions without a workflow.
Bar chart of accuracy change versus Base, Direct per benchmark for Base, Stage 1 and DynaFlow in Forced mode, with Base plus web search as diamonds. Base, Forced loses 4 to 23 points except on HotpotQA; Stage 1 and DynaFlow gain on all six.
Workflows help only after training. Change versus Base, Direct. Untrained workflows hurt everywhere except HotpotQA; trained ones help on all six benchmarks.
WORKFLOW ANALYSIS

How the programs use information.

First workflows under Forced execution, before and after training.

CODE

Three ways to run.

Direct

The Main Agent answers without invoking a workflow.

Dynamic

The Main Agent decides when a workflow will help.

Forced

Every task runs through a workflow.

python scripts/dynaflow.py demo --mode direct
python scripts/dynaflow.py demo --mode dynamic
python scripts/dynaflow.py demo --mode forced

Setup instructions are in the repository README.

Citation

If you find our work or this codebase helpful, please cite our paper:

@article{liu2026dynaflow,
  title={DynaFlow: Learning Free-Form Multi-Agent Orchestration},
  author={Liu, Ruhao and Li, Qi and Wang, Shizun and Wang, Xinchao},
  journal={arXiv preprint arXiv:2610.34467},
  year={2026}
}

Paper figure

Open image ↗

Use “Zoom to original” for small labels. Scroll to inspect; press Escape to close.