DyFlow: Dynamic Workflow Framework for Agentic Reasoning

Yanbo Wang, Zixiang Xu, Yue Huang, Xiangqi Wang, Zirui Song, Lang Gao, Chenxi Wang, Xiangru Tang, Yue Zhao, Arman Cohan, Xiangliang Zhang, Xiuying Chen

TL;DR

DyFlow is a new framework that allows Large Language Model (LLM) agents to dynamically build and adjust their own reasoning workflows in real-time based on intermediate feedback. By separating the "Designer" (the planner) from the "Executor" (the doer), DyFlow moves beyond rigid, pre-defined scripts to achieve state-of-the-art performance across math, coding, and complex social reasoning tasks.

What Problem Does This Paper Address?

Building an LLM "agent" usually involves defining a workflow—a sequence of steps like "first search, then summarize, then verify." Currently, most of these workflows are static: they are hard-coded by humans or optimized for a specific dataset.

Evolution of Agent Workflows

The problem is that real-world reasoning is messy. If a static agent hits an unexpected error or a sub-task fails, the whole system often collapses because it lacks a mechanism to "re-plan." Existing "automated" workflow generators are often "one-shot," meaning they create a plan at the start and stick to it regardless of what happens during execution. The authors identify a critical gap: the lack of execution-adaptive workflows that can pivot based on real-time results and environmental feedback.

Methods

The authors introduce DyFlow, which operates on a hierarchical Designer-Executor architecture to enable dynamic replanning:

DyFlow Framework Architecture
  1. The Designer (DyPlanner): This acts as the "brain." Given a task, it doesn't plan the entire process at once. Instead, it generates a "stage subgraph"—a mini-plan for the immediate sub-goal. After the executor finishes that stage, the Designer evaluates the output (and any errors) to decide the next move: proceed, revise the previous step, or terminate.
  2. The Executor: This component carries out the specific instructions using a set of Dynamic Operators (e.g., DECOMPOSE_PROBLEM, GENERATE_CODE, or REVIEW_SOLUTION). These are not just static prompts; they are flexible templates that the Designer fills with context-aware parameters.
  3. Two-Phase Training: To make the Designer effective even in smaller models (like the 14B Phi-4), the authors utilized a specialized training pipeline:
  4. Knowledge Distillation: Training on successful reasoning paths generated by "teacher" models (like GPT-4).
  5. Self-Play Preference Optimization (KTO): The model interacts with the executor, generates its own trajectories, and learns to favor plans that lead to success while discarding those that lead to failure.

Datasets

The framework was trained and evaluated across five diverse domains to test its cross-task generalization capabilities:

  • Math Reasoning: MATH benchmark (Level 5 problems).
  • Medical QA: PubMedQA.
  • Logical Reasoning: LiveBench.
  • Code Generation: HumanEval (used for zero-shot evaluation).
  • Social Reasoning: SocialMaze (a complex multi-turn social deduction game, also used for zero-shot evaluation).

Key Insights and Ideas

  • Feedback-Driven Replanning: The core insight is that an agent doesn't need to be a perfect "prophet" if it is a good "editor." By re-evaluating the plan after every single execution step, DyFlow can catch critical flaws (like ignoring a mathematical edge case) that would otherwise derail a standard Chain-of-Thought (CoT) approach.
  • Emergent Control Flow: Unlike other frameworks that rely on complex code to handle "if-else" or "while" loops, DyFlow achieves this naturally. If the Designer sees a REVIEW_SOLUTION step return a "Major Issues" verdict, it simply generates a REFINE subgraph next. The logic emerges organically from the planning loop rather than being hard-coded.
  • Small Models, Big Brains: One of the most impressive findings is that a 14B parameter model (DyPlanner), when trained with this feedback-aware strategy, can match or outperform proprietary giants like GPT-4.1 or Claude-3.7-Sonnet in planning quality.

Key Results

  • Superior Accuracy: DyFlow achieved an average accuracy of 61.45% across all tasks, significantly outperforming Vanilla prompting (53.44%) and standard Chain-of-Thought (54.43%).
  • Zero-Shot Generalization: Even though it wasn't explicitly trained on social reasoning or coding, DyFlow crushed baselines on SocialMaze (17.18 vs. 6.49 for Vanilla) and HumanEval (92.07% vs. 86.59%).
  • Stability (Pass@k): In "Pass@5" tests (giving the model 5 attempts), DyFlow reached near-perfect scores (98%+) on coding tasks. This demonstrates that its structured planning makes it much more likely to eventually find the right path compared to random sampling.
  • Cost Efficiency: The trained DyPlanner model is significantly cheaper to run than using high-end proprietary models as designers, reducing inference costs by up to 98% while maintaining top-tier performance.

Limitations and Future Work

The authors are transparent about a few current hurdles:

  • Tool Integration: Currently, DyFlow is mostly "symbolic"—it excels at math and logic but lacks built-in support for external tools like search engines, databases, or web browsers.
  • Computational Overhead: Because the Designer re-plans at every step, it consumes more tokens than a simple one-shot prompt (though it remains much cheaper than "multi-agent debate" systems).
  • Future Directions: The team plans to expand the operator set to include environmental interaction (such as robotics or web navigation) and integrate richer error-detection signals to help the Designer pivot even more accurately.

Summary updated

BibTeX
@inproceedings{wang2025dyflow,
  author = {Yanbo Wang and Zixiang Xu and Yue Huang and Xiangqi Wang and Zirui Song and Lang Gao and Chenxi Wang and Xiangru Tang and Yue Zhao and Arman Cohan and Xiangliang Zhang and Xiuying Chen},
  title = {{DyFlow: Dynamic Workflow Framework for Agentic Reasoning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=0pbUfmwNTy},
}
Figure