HierFlow: Hierarchical Coupled Dual-Space Search for Automatic Agentic Workflow Generation

Dong Li, Yanchi Liu, Xujiang Zhao, Wei Cheng, Zhengzhang Chen, Xintao Wu, Zhong Chen, Haifeng Chen, Chen ZhaoNeurIPS 2026

TL;DR

Teaching an AI agent how to break down and solve a complex problem usually requires either rigid human-written scripts or expensive offline training. HierFlow solves this on the fly at test time—no training required—by splitting the problem into two talking halves: a high-level "architect" that sketches the task graph and a low-level "coder" that writes and tests executable sub-steps. Because the coder's failures can force the architect to redraw the blueprint, the system dynamically adapts to tricky, unseen problems without blowing your compute budget.

What Problem Does This Paper Address?

Large Language Models (LLMs) are much smarter when organized into agentic workflows—multi-step pipelines where models decompose tasks, reason, write code, and critique each other. Early workflows (like Chain-of-Thought or Debate) were handcrafted and static. Lately, researchers have tried to automatically search for the best workflow.

Because "all possible workflows" is an impossibly huge, abstract space, researchers search over proxy spaces—concrete representations like Python code, natural language plans, or Directed Acyclic Graphs (DAGs).

Three equivalent workflow proxy representations—natural language, a DAG, and Python code—for the same geometry question.

Here is the catch: existing automated methods either search offline to find one-size-fits-all templates for a whole dataset, or train neural workflow designers on fixed distributions. Both approaches cost a fortune in data and engineering, and both stumble when hit with out-of-distribution queries. Meanwhile, searching at test-time inside a single proxy space is clunky: graphs lack execution precision, while raw code spaces are too combinatorially vast to search from scratch.

Methods

HierFlow introduces a training-free, test-time hierarchical search that couples two complementary proxy spaces in a closed loop:

  1. Upper-Level Topology Search (The Architect): Given a query, an LLM proposes candidate DAGs where each node is a subtask. It picks the best structure based on dependency complexity and LLM-judged coverage, then executes subtasks layer by layer.
  2. Lower-Level Code Search (The Coder): Rather than searching for one giant program, each subtask node defines a much smaller, localized Python code space. HierFlow uses a lightweight tree search inspired by Monte Carlo Tree Search (MCTS)—expanding candidate Python sub-workflows in parallel, running them in a sandbox with mock inputs to check executability, and scoring them via an LLM evaluator.
  3. Bidirectional Coupling: Unlike a rigid top-down pipeline, execution informs structure. If more than half of a subtask's code candidates crash, or their quality scores vary wildly, the lower level fires a refinement signal upward. The upper level then rewires the DAG—adding, deleting, or reordering subtasks while keeping completed work intact.
  4. Adaptive Gating (The Budget Controller): Running tree search on every subtask is wasteful. HierFlow introduces a Search Necessity Proxy ($Z_i = S_i \cdot U_i$), multiplying how much search space remains ($S_i$) by the model's uncertainty/entropy ($U_i$) on a quick baseline attempt. Only subtasks exceeding a threshold $\tau$ trigger deep code search.

Datasets

Because HierFlow is completely training-free, datasets are used strictly for test-time evaluation across three domains (all powered by gpt-4o-mini):

  • Question Answering: HotpotQA
  • Mathematical Reasoning: GSM8K and MATH
  • Code Generation: HumanEval and MBPP

No new benchmarks are introduced.

Key Insights and Ideas

  • Plans and implementations shouldn't be divorced: Freezing an initial task breakdown (a standard divide-and-conquer pipeline) fails when an early step turns out to be practically unimplementable. Letting execution failures trigger graph rewiring makes the workflow self-healing.
  • Divide-and-conquer has a measurable breaking point: Through a theoretical coupling-aware analysis, the authors show that hierarchical search shines when subtasks have sparse, balanced dependencies. If tasks are tightly tangled (high edge density or constant repair triggers), synchronization overhead eats away the efficiency gains.
  • Uncertainty + Remaining Space = Smart Budgeting: Combining token-level predictive entropy with unexplored tree volume gives a remarkably reliable, zero-training knob ($\tau$) to allocate test-time compute only where the agent is actually stumped.

Key Results

  • Across-the-board state-of-the-art: HierFlow achieves an average score of 78.74% across all five benchmarks—beating vanilla gpt-4o-mini (72.17%), handcrafted workflows like Self-Consistency (73.69%), and offline-trained/searched baselines like MaAS (77.42%) and AFlow (76.96%). On the tough MATH dataset, HierFlow hits 53.70%, outperforming DyFlow (52.67%) even though DyFlow was explicitly trained on MATH.
  • Zero-degradation generalization: When baselines optimized on HumanEval are tested on HotpotQA, performance drops by 2.63 to 4.00 percentage points. HierFlow suffers 0.00% degradation because it synthesizes bespoke workflows per query at inference time.
  • Efficiency sweet spot: Ablations on MATH show that searching code without a topology graph costs $0.036 and 8.21 minutes per query for 51.23% accuracy. HierFlow ($\tau=4$) reaches **53.70%** accuracy at nearly half the cost (**$0.020, 4.13 minutes**). Turning off gating ($\tau=0$) nudges accuracy to 55.14%, but inflates cost by 35% and time by nearly 50%.

Limitations and Future Work

  • Degradation under tight coupling: As the authors explicitly prove in Theorem 3.2, HierFlow's efficiency relies on subtasks being reasonably modular. When problems have dense cross-subtask dependencies or trigger repeated structural repairs, rewinding and re-execution costs mount quickly.
  • Test-time latency and judge reliance: Even with gating, HierFlow takes ~4.13 minutes per query on MATH and relies heavily on LLM-based evaluators to score both graph topologies and code semantics.
  • Future work directions are not explicitly discussed in the main text of the paper.

Summary updated

Abstract

Agentic AI systems enable LLMs to solve non-trivial tasks through structured workflows, but automatically generating such workflows remains challenging due to the discrete and combinatorial search space. Existing methods often rely on offline search or training, limiting query-level adaptability and incurring substantial data and engineering overhead. We formulate workflow generation as a coupled topology--execution search problem, where the upper-level topology induces subtask-specific code-search domains and lower-level execution feedback can revise the topology itself. Based on this formulation, we propose HierFlow, a training-free hierarchical test-time search framework for automatic agentic workflow generation. HierFlow couples feedback-driven topology refinement with an MCTS-inspired lightweight tree search for execution-level sub-workflow optimization, and uses an adaptive gating mechanism to selectively trigger execution-level search based on estimated necessity. We further provide a coupling-aware analysis characterizing when hierarchical decomposition and proxy-based gating are beneficial and when their advantages may degrade under stronger cross-subtask coupling. Experiments across QA, mathematical reasoning, and code generation benchmarks show that HierFlow achieves strong performance and favorable efficiency--quality trade-offs, outperforming competitive baselines without additional training.
BibTeX
@inproceedings{li2026hierflow,
  author = {Dong Li and Yanchi Liu and Xujiang Zhao and Wei Cheng and Zhengzhang Chen and Xintao Wu and Zhong Chen and Haifeng Chen and Chen Zhao},
  title = {{HierFlow: Hierarchical Coupled Dual-Space Search for Automatic Agentic Workflow Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=oFWYxd9QWu},
}
Figure