From Search to Synthesis: Training LLMs as Zero-Shot Workflow Generators
Summary
Introduces MetaFlow, a method that trains large language models to generate zero-shot workflows for tasks by combining supervised fine-tuning and reinforcement learning with execution feedback, achieving strong generalization to untrained tasks and operator sets.
View Cached Full Text
Cached at: 07/01/26, 05:31 AM
# From Search to Synthesis: Training LLMs as Zero-Shot Workflow Generators
Source: [https://arxiv.org/html/2606.30704](https://arxiv.org/html/2606.30704)
###### Abstract
Large language models \(LLMs\) excel across a wide range of tasks, yet their instance\-specific solutions often lack the structural consistency needed for reliable deployment\. Workflows that encode recurring algorithmic patterns at the task level provide a principled framework, offering robustness across instance variations, interpretable traces for debugging, and reusability across problem instances\. However, manually designing such workflows requires significant expertise and effort, limiting their broader application\. While automatic workflow generation could address this bottleneck, existing methods either produce instance\-specific solutions without learning task\-level patterns, or cannot generalize beyond their training configurations\. We presentMetaFlow, which casts workflow generation as a meta\-learning problem: given a task and an operator set, the model learns to compose solution strategies\. MetaFlow trains in two stages: supervised fine\-tuning on synthetic workflow data, followed by reinforcement learning with verifiable rewards \(RLVR\) that uses execution feedback across problem instances in the task to improve end\-to\-end success\. The resulting model produces effective workflows for trained tasks and exhibits strong generalization to untrained tasks and novel operator sets\. Across benchmarks in question answering, code generation, and mathematical reasoning, MetaFlow achieves performance comparable to state\-of\-the\-art baselines on in\-domain tasks with single inference, while demonstrating remarkable zero\-shot generalization capabilities on out\-of\-domain tasks and operator sets\.
## 1Introduction
Large Language Models \(LLMs\) have demonstrated significant performance across a wide range of tasks, including code generation, question answering, and mathematical reasoning\(Austinet al\.,[2021](https://arxiv.org/html/2606.30704#bib.bib14); Chenet al\.,[2021](https://arxiv.org/html/2606.30704#bib.bib16); Yanget al\.,[2018](https://arxiv.org/html/2606.30704#bib.bib13); Duaet al\.,[2019](https://arxiv.org/html/2606.30704#bib.bib17); Dinget al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib19); Jianget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib20); Cobbeet al\.,[2021](https://arxiv.org/html/2606.30704#bib.bib15); OpenAI,[2023](https://arxiv.org/html/2606.30704#bib.bib21); Zhu and others,[2024](https://arxiv.org/html/2606.30704#bib.bib22)\)\. However, because these models generate instance\-specific solutions, they lack the structural consistency and transparency needed for reliable deployment, while also being difficult to adapt to similar tasks\.Workflowsthat encode recurring algorithmic patterns provide a principled alternative, decomposing complex challenges into structured, manageable steps\. However, manually designing such workflows requires significant expertise and effort, limiting their broader application\.
To address this challenge, recent effort have focused on the automatic workflow generation\(Khattabet al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib23); Liet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib24); Songet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib25); Zhanget al\.,[2024a](https://arxiv.org/html/2606.30704#bib.bib26)\)\. Endowing LLMs with this strategy planning capability means lowering the barrier for complex task automation from requiring manual programming by experts to merely providing high\-level task descriptions, thereby greatly liberating productivity\. Nevertheless, representing the workflow as static graph\(Zhugeet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib28)\)or neural network\(Liuet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib29)\)in many of these methods limits the flexibility of generatable workflows\.
A promising direction emerges from works like ADAS\(Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30)\), AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\), ScoreFlow\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\)and FlowReasoner\(Gaoet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib32)\), which represent workflows as code \(a structured combination of predefinedoperators\), making the automatic generation of workflows more flexible and expressive, whereoperatoris an encapsulation of common agentic operations introduced byZhanget al\.\([2024b](https://arxiv.org/html/2606.30704#bib.bib4)\)\. Within this code\-based framework, current approaches adopt two different paradigms for workflow generation\.
Figure 1:Illustration ofinstance\-level,task\-level, andmeta\-level \(ours\)workflow generation approaches\. Unlikeinstance\-levemethods that generate workflows for individual problems ortask\-levelmethods that require costly search for each new task, our meta\-learning approach enables zero\-shot workflow generation across tasks\.The first paradigm comprisestask\-levelapproaches, exemplified by ADAS\(Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30)\)and AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\), which formulate workflow generation as a search problem within predefined task\-operator set combination\. Both methods employ iterative search strategies, with ADAS using evolutionary algorithms and AFlow using Monte Carlo Tree Search \(MCTS\), to discover high\-performing workflows through repeated refinement\. However, this search\-based paradigm inherently constrains them to specific task and predetermined operator set\. When encountering new tasks or operators, these methods require complete re\-optimization from scratch, incurring substantial computational costs\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\)\.
Conversely, the second paradigm consists ofinstance\-levelapproaches, exemplified by ScoreFlow\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\)and FlowReasoner\(Gaoet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib32)\), which generate workflows tailored to individual problem instances in the task\. Both methods dynamically construct workflows at inference time, with ScoreFlow leveraging gradient\-based optimization to refine agentic workflows, and FlowReasoner employing reasoning chains distilled from advanced models to design query\-specific multi\-agent systems\. While these instance\-level methods excel at tailoring workflows to specific problem instances, this granularity comes at the cost of reusability and deployment efficiency\. They cannot capture task\-level patterns that recur across similar problem instances, leading to redundant workflow generation for each query\. In deployment scenarios, this approach foregoes the benefits of having optimized, reusable workflow templates that could be consistently applied to entire task\.
The limitations of existing paradigms underscore two fundamental challenges that must be addressed to achieve truly general\-purpose automatic workflow generation\.\(1\) How can we overcome the re\-optimization requirement of task\-level approaches when facing new domains \(task\-operator set combinations\)? \(2\) How can we learn generalizable patterns that avoid redundant instance\-level generation while adapting effectively to untrained domains?
To systematically overcome the challenges, we proposeMetaFlow, which formulates workflow generation as a meta\-learning problem\. As illustrated in Figure[1](https://arxiv.org/html/2606.30704#S1.F1), unlike task\-level search\-based methods that require expensive re\-optimization for new task\-operator set combinations, and instance\-level methods that generate workflows for individual queries,MetaFlowlearns to directly synthesize workflows from task descriptions and operator set specifications, enabling zero\-shot generation through a single model inference\.
To achieve robust zero\-shot generalization,MetaFlowemploys a two\-stage training paradigm with diverse task\-operator pairs\. Adopting the code\-based workflow representation from prior works\(Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30); Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4); Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27); Gaoet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib32)\), we first synthesize thousands of workflows usingQwen\-Max\(Team,[2024](https://arxiv.org/html/2606.30704#bib.bib34)\)across four tasks and a single operator set to finetuneQwen3\-8B\(Yanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib33)\), establishing the foundation for understanding how tasks and operators relate to workflow structures\. Subsequently, we apply online reinforcement learning with GRPO\(Shaoet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib8)\)across expanded domains, where execution feedback on problem instances directly optimizes the generation policy\. This training ensures the model learns generalizable workflow construction principles rather than memorizing patterns\. At inference,MetaFlowzero\-shot generates effective workflows for novel configurations with only a single forward pass\.
Our main contributions are:
- •Meta\-learning Framework: We introduceMetaFlow, a novel approach that reformulates workflow generation from discrete search within fixed configurations to continuous learning across diverse task\-operator set combinations\. By conditioning workflow generation on task descriptions and operator specifications, our framework achieves strong zero\-shot generalization to unseen domains without any re\-optimization, reducing computational cost from thousands of API calls to a single model inference\.
- •Scalable Training Pipeline: We design a two\-stage training framework combining supervised learning with online reinforcement learning, utilizing diverse domains to ensure robust generalization to untrained domains\.
- •Comprehensive Evaluation: Extensive experiments demonstrate thatMetaFlowachieves competitive performance on in\-domain benchmarks while exhibiting remarkable zero\-shot generalization to out\-of\-domain task classes and operator sets, including solving programming problems with novel operator combinations never seen during training and solving question answering problem using the vector database search operator\.
## 2Related Works
### 2\.1Agentic Workflow
Agentic workflows decompose complex tasks into structured steps through predefined operators and dependencies\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4); Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27); Gaoet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib32)\)\. Unlike autonomous agents that learn through environment interaction\(Zhugeet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib28); Honget al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib37)\), workflows provide interpretable and consistent execution patterns\. Recent works adopt code\-based representations for superior expressiveness\(Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30); Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4); Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27); Gaoet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib32)\), supporting applications in code generation, question answering, and mathematical reasoning\(Austinet al\.,[2021](https://arxiv.org/html/2606.30704#bib.bib14); Chenet al\.,[2021](https://arxiv.org/html/2606.30704#bib.bib16); Yanget al\.,[2018](https://arxiv.org/html/2606.30704#bib.bib13); Duaet al\.,[2019](https://arxiv.org/html/2606.30704#bib.bib17); Dinget al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib19); Jianget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib20); Cobbeet al\.,[2021](https://arxiv.org/html/2606.30704#bib.bib15); OpenAI,[2023](https://arxiv.org/html/2606.30704#bib.bib21); Zhu and others,[2024](https://arxiv.org/html/2606.30704#bib.bib22)\)\. However, manual workflow design remains a significant bottleneck requiring deep expertise\.
### 2\.2Automatic Workflow Generation
Recent advances have explored automating workflow generation for improving LLM performance\(Chenet al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib40); Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4); Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27); Liet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib24); Songet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib25)\)\. While some methods optimize prompts within fixed workflows\(Guoet al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib42); Khattabet al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib23)\), we focus on optimizing workflow structures directly\.
Current structural optimization follows two paradigms\. Task\-level approaches like ADAS\(Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30)\)and AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\)search for optimal workflows through evolutionary algorithms or MCTS, but require complete re\-optimization for new domains\. Instance\-level methods including ScoreFlow\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\)and FlowReasoner\(Gaoet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib32)\)generate query\-specific workflows but fail to extract reusable patterns\.
Our Methods,MetaFlowreformulates workflow generation as meta\-learning over diverse task\-operator combinations during training\. Through two\-stage optimization combining supervised learning with reinforcement learning, it achieves true zero\-shot generation—producing effective workflows for novel domains via single model inference, eliminating both re\-optimization and adaptation overhead\.
## 3Problem Definition
Existing works often formulate automatic workflow generation as optimization problems\(Xuet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib36); Liet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib5)\), requiring separate optimizations for each task\. We elevate this perspective by reformulating it as a meta\-learning problem\(Finnet al\.,[2017](https://arxiv.org/html/2606.30704#bib.bib6); Franceschiet al\.,[2018](https://arxiv.org/html/2606.30704#bib.bib7)\)\. To ground this formulation, we first define our core concepts:
- •Problem Instance𝗉\\displaystyle\\mathsf\{p\}: A single, concrete problem to be solved\.
- •Task𝖢\\displaystyle\\mathsf\{C\}: A family of problem instances sharing a common structure and solution strategy \(e\.g\., GSM8K mathematical reasoning, DROP reading comprehension\)\.
- •Operator Set𝖮𝗉𝗌\\displaystyle\\mathsf\{Ops\}: A collection of fundamental, reusable operations\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\)\(e\.g\.,Generate,Revise,Ensemble\)\.
- •Domain\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{\(C,Ops\)\}: The combination of a task and an operator set, defining a complete problem\-solving context\.
Within this meta\-learning framework, an LLM serves as the meta\-learner \(the plannerπθ\\displaystyle\\pi\_\{\\theta\}\)\. Its core responsibility is to learn a meta\-strategy that enables fast adaptation: given any domain\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{\(C,Ops\)\}, the planner rapidly generates an efficient and reusableWorkflow𝖶\\displaystyle\\mathsf\{W\}—a structured sequence of operators from𝖮𝗉𝗌\\displaystyle\\mathsf\{Ops\}\. When executed on anyProblem Instance𝗉\\displaystyle\\mathsf\{p\}from task𝖢\\displaystyle\\mathsf\{C\}, this workflow produces a high\-qualitySolution𝗌\\displaystyle\\mathsf\{s\}\.
Unlike traditional meta\-learning approaches such as Model\-Agnostic Meta\-Learning \(MAML\)\(Finnet al\.,[2017](https://arxiv.org/html/2606.30704#bib.bib6)\), which rely on gradient updates for adaptation, our method achieves fast adaptation through the synthesis of workflows without requiring any gradient\-based fine\-tuning\.
As a meta\-learning task, our goal is to optimize the meta\-parametersθ\\displaystyle\\thetaof the plannerπθ\\displaystyle\\pi\_\{\\theta\}such that the generated workflows maximize expected rewards across the domain distribution𝒟\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathcal\{D\}\_\{\\mathsf\{\(C,Ops\)\}\}\. We adopt the classicbi\-level optimizationframeworkFranceschiet al\.\([2018](https://arxiv.org/html/2606.30704#bib.bib7)\):
J\(θ;𝖢,𝖮𝗉𝗌\)\\displaystyle\\displaystyle J\(\\theta;\\mathsf\{C\},\\mathsf\{Ops\}\)=𝔼𝖶∼πθ\(⋅∣𝖢,𝖮𝗉𝗌\)\[𝔼𝗉∼𝖢\[R\(Exec\(𝖶,𝗉\)\)\]\]\\displaystyle\\displaystyle=\\mathbb\{E\}\_\{\\mathsf\{W\}\\sim\\pi\_\{\\theta\}\(\\cdot\\mid\\mathsf\{C\},\\mathsf\{Ops\}\)\}\[\\mathbb\{E\}\_\{\\mathsf\{p\}\\sim\\mathsf\{C\}\}\[R\(\\text\{Exec\}\(\\mathsf\{W\},\\mathsf\{p\}\)\)\]\]θ∗\\displaystyle\\displaystyle\\theta^\{\*\}=argmaxθ𝔼\(𝖢,𝖮𝗉𝗌\)∼𝒟\(𝖢,𝖮𝗉𝗌\)\[J\(θ;𝖢,𝖮𝗉𝗌\)\]\\displaystyle\\displaystyle=\\arg\\max\_\{\\theta\}\\mathbb\{E\}\_\{\\mathsf\{\(C,Ops\)\}\\sim\\mathcal\{D\}\_\{\\mathsf\{\(C,Ops\)\}\}\}\[J\(\\theta;\\mathsf\{C\},\\mathsf\{Ops\}\)\]where:
- •\(𝖢,𝖮𝗉𝗌\)∼𝒟\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{\(C,Ops\)\}\\sim\\mathcal\{D\}\_\{\\mathsf\{\(C,Ops\)\}\}: Sample a domain \(task\-operator pair\) from the distribution\.
- •𝖶∼πθ\(⋅∣𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{W\}\\sim\\pi\_\{\\theta\}\(\\cdot\\mid\\mathsf\{C\},\\mathsf\{Ops\}\): The planner performsfast adaptation—given task description𝖢\\displaystyle\\mathsf\{C\}and operator specifications𝖮𝗉𝗌\\displaystyle\\mathsf\{Ops\}, it generates a customized workflow𝖶\\displaystyle\\mathsf\{W\}without gradient updates\.
- •𝗉∼𝖢\\displaystyle\\mathsf\{p\}\\sim\\mathsf\{C\}: Sample problem instances from task𝖢\\displaystyle\\mathsf\{C\}to evaluate the workflow\.
- •Exec\(𝖶,𝗉\)\\displaystyle\\text\{Exec\}\(\\mathsf\{W\},\\mathsf\{p\}\): Execute workflow𝖶\\displaystyle\\mathsf\{W\}on problem𝗉\\displaystyle\\mathsf\{p\}to produce a solution\.
- •R\(⋅\)\\displaystyle R\(\\cdot\): Reward function evaluating solution quality \(e\.g\., test pass rate, answer correctness\)\.
Theouter loopoptimizes performance across the entire domain distribution𝒟\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathcal\{D\}\_\{\\mathsf\{\(C,Ops\)\}\}rather than on individual tasks or instances, driving the meta\-learnerπθ\\displaystyle\\pi\_\{\\theta\}to acquire cross\-domain generalization capabilities\. This contrasts sharply with prior works:
- •Instance\-level methods\(e\.g\., ScoreFlow\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\), ComfyUI\-R1\(Xuet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib36)\)\) optimize workflows for individual problem instances:argmax𝖶𝗉𝔼𝗉∼𝖢\[R\(Exec\(𝖶𝗉,𝗉\)\)\]\\displaystyle\\arg\\max\_\{\\mathsf\{W\}\_\{\\mathsf\{p\}\}\}\\mathbb\{E\}\_\{\\mathsf\{p\}\\sim\\mathsf\{C\}\}\[R\(\\text\{Exec\}\(\\mathsf\{W\}\_\{\\mathsf\{p\}\},\\mathsf\{p\}\)\)\]\.
- •Task\-level methods\(e\.g\., AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\)\) optimize a single workflow per task but require separate optimization for each new task\-operator combination\.
Our framework elevates to themeta\-level, learning a planner that generalizes across tasks and operators:𝖶∼πθ\(⋅∣𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{W\}\\sim\\pi\_\{\\theta\}\(\\cdot\\mid\\mathsf\{C\},\\mathsf\{Ops\}\)\.
## 4Methodology
OurMetaFlowframework aims to train a large language model through a two\-stage learning process to automatically generate efficient and reusable workflows for given domains\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{\(C,Ops\)\}, where𝖢\\displaystyle\\mathsf\{C\}represents a task and𝖮𝗉𝗌\\displaystyle\\mathsf\{Ops\}denotes the available operator set\. The framework addresses a key challenge in automated workflow generation: how to enable a model to quickly adapt to new domains \(task\-operator combinations\) without requiring extensive training data for each\. This section presents our system architecture \(Section[4\.1](https://arxiv.org/html/2606.30704#S4.SS1)\) and the two\-stage training algorithm combining supervised fine\-tuning and reinforcement learning with verifiable rewards \(Section[4\.2](https://arxiv.org/html/2606.30704#S4.SS2)\)\.
### 4\.1MetaFlow Architecture
The core architecture ofMetaFlowconsists of two components: \(1\) aplanner LLMπθ\\displaystyle\\pi\_\{\\theta\}that generates workflows conditioned on domain specifications\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{\(C,Ops\)\}, and \(2\) anexecution\-evaluation environmentthat orchestrates workflow execution using the MetaGPT framework\(Honget al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib9)\), invokes operators on sampled problem instances, and computes verifiable reward scores based on correctness evaluation\.
Workflow Representation: A workflow is represented as a structured script based on the MetaGPT framework\(Honget al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib9)\), composed of a series of predefined operator calls\. As illustrated in the left part of Figure[2](https://arxiv.org/html/2606.30704#S4.F2), we adopt the foundational text\-processing operators from AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\), includingGenerate,Summarize,Revise,Ensemble, andProgrammerfor basic tool invocation\. Building upon the same MetaGPT interface, we further introduce additional operators for advanced text processing \(e\.g\.,Decompose[1](https://arxiv.org/html/2606.30704#LST1),SelfConsistency\) and domain\-specific tools \(e\.g\.,VectorSearch[3](https://arxiv.org/html/2606.30704#LST3)\)\. This standardized operator interface serves two purposes: \(1\) supervised fine\-tuning provides a cold start that ensures the model generates syntactically valid operator calls with higher probability, and \(2\) the introduction of new operators demonstrates the necessity of our meta\-learning approach for efficient and transferable workflow generation across diverse operator sets\. Implementation details of the operators are provided in Appendix[B\.1](https://arxiv.org/html/2606.30704#A2.SS1)for reference\.
Figure 2:Overview of MetaFlow architecture\.Left:Basic operators and their functionalities, including text\-processing operators \(Generate,Summarize,Revise,Ensemble\) and basic tool\-invocation operators \(Programmer\)\.Right:The MetaFlow training framework showing how the planner model generates workflows conditioned on domain\(𝖢,𝖮𝗉𝗌\)\\displaystyle\\mathsf\{\(C,Ops\)\}, which are then evaluated on problem instances to compute rewards for GRPO optimization\.Input\-Output: As illustrated in the right part of Figure[2](https://arxiv.org/html/2606.30704#S4.F2), themodel inputconsists of two parts:Task Description[4](https://arxiv.org/html/2606.30704#LST4), which elucidates the characteristics of the target task𝖢\\displaystyle\\mathsf\{C\}and the input\-output formats of problem instances;Operator Descriptions[5](https://arxiv.org/html/2606.30704#LST5), which define the functions, parameters, and input\-output formats of each available operator in𝖮𝗉𝗌\\displaystyle\\mathsf\{Ops\}\(whether pre\-defined or user\-defined\)\. Theoutput[6](https://arxiv.org/html/2606.30704#LST6)is a structuredWorkflowaimed at efficiently solving all problem instances from task𝖢\\displaystyle\\mathsf\{C\}using operator set𝖮𝗉𝗌\\displaystyle\\mathsf\{Ops\}\. This design paradigm allows users to introduce new operators and tasks through natural language descriptions at inference time, enabling the model to rapidly adapt without additional training\. Implementation details are provided in Appendix[B\.2](https://arxiv.org/html/2606.30704#A2.SS2)\.
Execution & Evaluation Environment: To achieve end\-to\-end optimization, we build an automated environment\. This environment receives a candidate workflow𝖶i\\displaystyle\\mathsf\{W\}\_\{i\}and a set ofN\\displaystyle Nproblem instances𝗉1,…,𝗉N\\displaystyle\\mathsf\{p\}\_\{1\},\\dots,\\mathsf\{p\}\_\{N\}sampled from task𝖢\\displaystyle\\mathsf\{C\}as input\. In the execution phase, the environment uses the MetaGPT framework to orchestrate the workflow\(Honget al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib9)\)\. Each operator in the workflow \(such asGenerate\) completes its specific subtask by calling an external lightweight language model API \(e\.g\.,Qwen\-TurboorGPT\-4o\-mini\-0718\) and processes each problem instance\. Upon completion, an automated evaluator module verifies the correctness of each execution result, for example, by running unit tests or comparing outputs with ground truth answers\. Based on the evaluation results, the environment computes a verifiable reward scoreR\(𝖶i\)\\displaystyle R\(\\mathsf\{W\}\_\{i\}\)for workflow𝖶i\\displaystyle\\mathsf\{W\}\_\{i\}, calculated as the average success rate overN\\displaystyle Ninstances:
R\(𝖶i\)=1N∑j=1N𝕀\(is correct\(Exec\(𝖶i,𝗉j\)\)\)\\displaystyle\\displaystyle R\(\\mathsf\{W\}\_\{i\}\)=\\frac\{1\}\{N\}\\sum\_\{j=1\}^\{N\}\\mathbb\{I\}\(\\text\{is correct\}\(\\text\{Exec\}\(\\mathsf\{W\}\_\{i\},\\mathsf\{p\}\_\{j\}\)\)\)\(1\)where𝕀\(⋅\)\\displaystyle\\mathbb\{I\}\(\\cdot\)is the indicator function\. This reward scoreR\(𝖶i\)\\displaystyle R\(\\mathsf\{W\}\_\{i\}\)is then passed to the training algorithm as the basis for policy updates\.
### 4\.2Training Algorithm
The training process consists of two stages:supervised fine\-tuning \(SFT\)andReinforcement Learning with Verifiable Reward \(RLVR\)\. This design leverages supervised data to establish syntactic correctness, then employs reinforcement learning to optimize workflow effectiveness, separating structural learning from performance optimization\.
#### 4\.2\.1Phase One: SFT Initialization
To address the cold start problem in reinforcement learning, we first performsupervised fine\-tuning \(SFT\)on the base LLM using a dataset of \(\[𝖢,𝖮𝗉𝗌\],𝖶\\displaystyle\[\\mathsf\{C\},\\mathsf\{Ops\}\],\\mathsf\{W\}\) pairs, which is the pairs of domain\[𝖢,𝖮𝗉𝗌\]\\displaystyle\[\\mathsf\{C\},\\mathsf\{Ops\}\]and the corresponding workflow𝖶\\displaystyle\\mathsf\{W\}\. This phase teaches the model to generate syntactically correct workflows following the required template structure \(Listing[6](https://arxiv.org/html/2606.30704#LST6)\) and proper operator invocation patterns \(Listing[5](https://arxiv.org/html/2606.30704#LST5)\)\. By ensuring the modelπθ\\displaystyle\\pi\_\{\\theta\}can produce well\-formed code, the subsequent RL phase can focus solely on optimizing workflow effectiveness rather than learning basic syntax, significantly narrowing the search space and accelerating convergence\. Details of the SFT dataset construction, including the four\-stage pipeline and LoRA configuration, are provided in Appendix[C](https://arxiv.org/html/2606.30704#A3)\.
#### 4\.2\.2Phase Two: RLVR Optimization
After SFT, we employ policy gradient algorithms to perform end\-to\-end self\-improvement on the plannerπθ\\displaystyle\\pi\_\{\\theta\}\. The core of this phase is theReinforcement Learning with Verifiable Reward \(RLVR\)loop, with the complete algorithm presented in Algorithm[1](https://arxiv.org/html/2606.30704#alg1)\. The specific process consists of the following steps:
1\.Policy Sampling: For a task𝖢\\displaystyle\\mathsf\{C\}sampled from the training set, the plannerπθ\\displaystyle\\pi\_\{\\theta\}generates a batch ofk\\displaystyle kcandidate workflows𝖶1,𝖶2,…,𝖶k\\displaystyle\\mathsf\{W\}\_\{1\},\\mathsf\{W\}\_\{2\},\\dots,\\mathsf\{W\}\_\{k\}\.
2\.Execution & Reward Calculation: Each candidate workflow𝖶i\\displaystyle\\mathsf\{W\}\_\{i\}is tested in the execution and evaluation environment described in Section[4\.1](https://arxiv.org/html/2606.30704#S4.SS1), obtaining its corresponding reward scoreR\(𝖶i\)\\displaystyle R\(\\mathsf\{W\}\_\{i\}\)executed onp1\(i\),⋯,pN\(i\)\\displaystyle p\_\{1\}^\{\(i\)\},\\cdots,p\_\{N\}^\{\(i\)\}\(Equation[1](https://arxiv.org/html/2606.30704#S4.E1)\) that reflects generalization capability:
C∈𝒟train\\displaystyle\\displaystyle C\\in\\mathcal\{D\}\_\{\\text\{train\}\}⟹πθ\{Wi\|1≤i≤k\}\\displaystyle\\displaystyle\\overset\{\\pi\_\{\\theta\}\}\{\\implies\}\\\{W\_\{i\}\|1\\leq i\\leq k\\\}⟹eachWi\{\[Wi,R\(Wi\)\]\|1≤i≤k\}\\displaystyle\\displaystyle\\overset\{\\text\{each \}W\_\{i\}\}\{\\implies\}\\\{\[W\_\{i\},R\(W\_\{i\}\)\]\|1\\leq i\\leq k\\\}3\.Policy Update: We use this batch of\[Wi,R\(Wi\)\]\\displaystyle\[W\_\{i\},R\(W\_\{i\}\)\]pairs to update the parameters of the plannerπθ\\displaystyle\\pi\_\{\\theta\}using theGroup Relative Policy Optimization \(GRPO\)algorithm\(Shaoet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib8)\)\. The core idea of GRPO is to use the average performance within the group as a baseline to estimate advantages, thereby avoiding training an independent value network\.
advantage=A^\(𝖶i\)=R\(𝖶i\)−μR,μR=∑j=1kR\(𝖶j\)/k\\displaystyle\\displaystyle\\text\{advantage\}=\\hat\{A\}\(\\mathsf\{W\}\_\{i\}\)=R\(\\mathsf\{W\}\_\{i\}\)\-\\mu\_\{R\},\\;\\mu\_\{R\}=\\sum\_\{j=1\}^\{k\}R\(\\mathsf\{W\}\_\{j\}\)/kThis group\-relative advantages makes the optimization signal derive from whether the workflow performance is better or worse than the current batch’s average level, rather than an absolute, potentially noisy value estimate\.
4\.Variance Reduction: Evaluation Based on Common Random Numbers: The effectiveness of policy gradients largely depends on the accuracy of the advantage functionA^\(𝖶i\)\\displaystyle\\hat\{A\}\(\\mathsf\{W\}\_\{i\}\)estimation\. In our GRPO method, the advantage is computed relative to the batch average rewardμR\\displaystyle\\mu\_\{R\}\. If each workflow𝖶i\\displaystyle\\mathsf\{W\}\_\{i\}in the batch is evaluated on a set of independently and randomly sampled problem instances, the variance of the rewardR\(𝖶i\)\\displaystyle R\(\\mathsf\{W\}\_\{i\}\)will include not only policy randomness but also environmental randomness\. This additional variance propagates toμR\\displaystyle\\mu\_\{R\}andA^\(𝖶i\)\\displaystyle\\hat\{A\}\(\\mathsf\{W\}\_\{i\}\), producing noisier gradients and reducing learning efficiency\.
To address this issue, we adopt a classic variance reduction technique:Common Random Numbers \(CRN\)\(Kleijnen,[1975](https://arxiv.org/html/2606.30704#bib.bib10)\)\. In specific implementation, we ensure that allk\\displaystyle kcandidate workflows𝖶1,…,𝖶k\\displaystyle\\mathsf\{W\}\_\{1\},\\dots,\\mathsf\{W\}\_\{k\}in the same training batch are evaluated on the exact same set of problem instances\{𝗉1,…,𝗉N\}\\displaystyle\\\{\\mathsf\{p\}\_\{1\},\\dots,\\mathsf\{p\}\_\{N\}\\\}\. By fixing the random variable of problem instances when comparing workflows, we eliminate noise arising from differences in problem sampling\. This keeps the expected value ofR\(𝖶i\)−R\(𝖶j\)\\displaystyle R\(\\mathsf\{W\}\_\{i\}\)\-R\(\\mathsf\{W\}\_\{j\}\)unchanged but significantly reduces its variance\. Ultimately, this ensures that our computed relative advantages more accurately reflect the intrinsic performance differences between workflows, leading to a more stable policy update direction and accelerating model convergence\.
Algorithm 1GRPO Optimization with CRN0:Training tasks
𝒟train\\displaystyle\\mathcal\{D\}\_\{\\text\{train\}\}, initial policy
πθ\\displaystyle\\pi\_\{\\theta\}, group size
k\\displaystyle k, batch size
B\\displaystyle B, iterations
T\\displaystyle T
1:for
t=1,…,T\\displaystyle t=1,\\ldots,Tdo
2:Batch Sampling:Sample tasks
\{𝖢1,…,𝖢B\}∼𝒟train\\displaystyle\\\{\\mathsf\{C\}\_\{1\},\\ldots,\\mathsf\{C\}\_\{B\}\\\}\\sim\\mathcal\{D\}\_\{\\text\{train\}\}
3:foreach
𝖢b\\displaystyle\\mathsf\{C\}\_\{b\}in batchdo
4:Policy Sampling:Generate
k\\displaystyle kworkflows
𝒲b=\{𝖶b,1,…,𝖶b,k\}\\displaystyle\\mathcal\{W\}\_\{b\}=\\\{\\mathsf\{W\}\_\{b,1\},\\ldots,\\mathsf\{W\}\_\{b,k\}\\\}
5:where
𝖶b,i∼πθ\(⋅\|𝖢b\)\\displaystyle\\mathsf\{W\}\_\{b,i\}\\sim\\pi\_\{\\theta\}\(\\cdot\|\\mathsf\{C\}\_\{b\}\)
6:Common Random Numbers:Fix problem set
𝒫b=\{𝗉1,…,𝗉N\}∼𝖢b\\displaystyle\\mathcal\{P\}\_\{b\}=\\\{\\mathsf\{p\}\_\{1\},\\ldots,\\mathsf\{p\}\_\{N\}\\\}\\sim\\mathsf\{C\}\_\{b\}
7:Reward Computation:For all
i∈\[1,k\]\\displaystyle i\\in\[1,k\]:
8:
R\(𝖶b,i\)=1N∑j=1N𝕀\[𝖶b,isolves𝗉j\]\\displaystyle R\(\\mathsf\{W\}\_\{b,i\}\)=\\frac\{1\}\{N\}\\sum\_\{j=1\}^\{N\}\\mathbb\{I\}\[\\mathsf\{W\}\_\{b,i\}\\text\{ solves \}\\mathsf\{p\}\_\{j\}\]
9:Group\-Relative Advantage:Compute baseline
μR,b=1k∑i=1kR\(𝖶b,i\)\\displaystyle\\mu\_\{R,b\}=\\frac\{1\}\{k\}\\sum\_\{i=1\}^\{k\}R\(\\mathsf\{W\}\_\{b,i\}\)
10:For all
i\\displaystyle i:
A^\(𝖶b,i\)=R\(𝖶b,i\)−μR,b\\displaystyle\\hat\{A\}\(\\mathsf\{W\}\_\{b,i\}\)=R\(\\mathsf\{W\}\_\{b,i\}\)\-\\mu\_\{R,b\}
11:endfor
12:Batch GRPO Update:
13:Collect all
\{\(𝖶b,i,A^\(𝖶b,i\)\)\}b=1,…,B;i=1,…,k\\displaystyle\\\{\(\\mathsf\{W\}\_\{b,i\},\\hat\{A\}\(\\mathsf\{W\}\_\{b,i\}\)\)\\\}\_\{b=1,\\ldots,B;i=1,\\ldots,k\}
14:Update:
θ←GRPO\(θ,\{\(𝖶b,i,A^\(𝖶b,i\)\)\}\)\\displaystyle\\theta\\leftarrow\\text\{GRPO\}\(\\theta,\\\{\(\\mathsf\{W\}\_\{b,i\},\\hat\{A\}\(\\mathsf\{W\}\_\{b,i\}\)\)\\\}\)
15:endfor
16:returnOptimized policy
πθ\\displaystyle\\pi\_\{\\theta\}
## 5Experiments
This section evaluatesMetaFlowthrough systematic experiments addressing three core questions: \(1\) CanMetaFlowachieve competitive performance with single\-inference generation, eliminating the computational overhead of per\-instance optimization? \(2\) Does the framework generalize to out\-of\-distribution tasks and novel operators unseen during training? \(3\) How do design choices—task\-level versus instance\-level generation, simple versus complex workflows—affect the performance\-cost trade\-off? We present training configuration, operator integration experiments, zero\-shot generalization results, and main performance analysis\.
### 5\.1Training Configuration
Stage 1: Supervised Fine\-Tuning \(SFT\) Initialization\.We first conduct supervised fine\-tuning \(SFT\) on the base modelQwen3\-8Bto teach the modelπθBase\\displaystyle\\pi\_\{\\theta\}^\{\\text\{Base\}\}to generate syntactically correct workflows \(Listing[6](https://arxiv.org/html/2606.30704#LST6)\) and narrow the search space\. We construct an expert dataset containing approximately1,300\\displaystyle 1,300high\-quality \(\[𝖢,𝖮𝗉𝗌\],𝖶\\displaystyle\[\\mathsf\{C\},\\mathsf\{Ops\}\],\\mathsf\{W\}\) pairs, covering the tasks𝒟trainSFT=\{GSM8K, DROP, MBPP, Humaneval\}\\displaystyle\\mathcal\{D\}\_\{\\text\{train\}\}^\{\\text\{SFT\}\}=\\\{\\text\{GSM8K, DROP, MBPP, Humaneval\}\\\}with the corresponding operator set for each task𝖮𝗉𝗌SFT=\(Generate,Summarize,Revise,Ensemble\)\\displaystyle\\mathsf\{Ops\}^\{\\text\{SFT\}\}=\(\\texttt\{Generate\},\\texttt\{Summarize\},\\texttt\{Revise\},\\texttt\{Ensemble\}\)\. The dataset is synthesized usingQwen\-MaxAPI through a four\-stage pipeline \(Appendix[C](https://arxiv.org/html/2606.30704#A3)\)\. As shown in Figure[3](https://arxiv.org/html/2606.30704#S5.F3)\(left and middle\), we train for one epoch with batch size16\\displaystyle 16using LoRA \(rank\-16\\displaystyle 16\)\(Huet al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib48)\)to prevent mode collapse on this limited dataset \(Appendix[C\.2](https://arxiv.org/html/2606.30704#A3.SS2)\)\.
Stage 2: Reinforcement Learning with Verifiable Rewards \(RLVR\) Optimization\.Following SFT initialization, we employ RLVR for end\-to\-end optimization of the plannerπθSFT\\displaystyle\\pi\_\{\\theta\}^\{\\text\{SFT\}\}with the same task set𝒟trainRLVR=𝒟trainSFT=\{GSM8K, DROP, MBPP, Humaneval\}\\displaystyle\\mathcal\{D\}\_\{\\text\{train\}\}^\{\\text\{RLVR\}\}=\\mathcal\{D\}\_\{\\text\{train\}\}^\{\\text\{SFT\}\}=\\\{\\text\{GSM8K, DROP, MBPP, Humaneval\}\\\}\. Critically, to enhance generalization to diverse operator configurations, we train with four different operator sets\{𝖮𝗉𝗌RLVR,i\}i=14\\displaystyle\\\{\\mathsf\{Ops\}^\{\\text\{RLVR\},i\}\\\}\_\{i=1\}^\{4\}that progressively introduce novel operators \(Programmer,Decompose\) beyond the base SFT set, randomly sampling domain combinations\(𝖢,𝖮𝗉𝗌\)\\displaystyle\(\\mathsf\{C\},\\mathsf\{Ops\}\)at each iteration\. The training employs Algorithm[1](https://arxiv.org/html/2606.30704#alg1)for137\\displaystyle 137steps\. To control training costs, the execution of generated workflow𝖶i\\displaystyle\\mathsf\{W\}\_\{i\}on problem instance𝗉j\\displaystyle\\mathsf\{p\}\_\{j\}calls theQwen\-TurboAPI\. As shown in Figure[3](https://arxiv.org/html/2606.30704#S5.F3)\(right\), the average reward rapidly increases from0\.67\\displaystyle 0\.67to approximately0\.88\\displaystyle 0\.88within the first35\\displaystyle 35training steps, then stabilizes around0\.85\\displaystyle 0\.85–0\.90\\displaystyle 0\.90, demonstrating the effectiveness of GRPO optimization with CRN\. We select the checkpoint at step100\\displaystyle 100for evaluation\. The details are provided in Appendix[D](https://arxiv.org/html/2606.30704#A4)\.



Figure 3:Training dynamics of MetaFlow\.Left:SFT training loss across different LoRA ranks \(with the same learning ratelr=0\.00002\\displaystyle lr=0\.00002\)\.Middle:SFT gradient norms showing convergent behavior\.Right:RLVR average reward demonstrating rapid policy improvement and stabilization\.
### 5\.2Low\-Cost Operator Integration: Continuous Library Expansion
A key advantage ofMetaFlowover task\-level search methods\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4); Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30)\)is its ability to continuously expand the operator library without costly re\-optimization\. To validate this capability, we demonstrate a practical workflow: abstracting a manually\-tested reasoning pattern into a reusable operator\. Specifically, we introduce theSelfConsistencyoperator \(see Appendix[2](https://arxiv.org/html/2606.30704#LST2)for complete implementation\), which encapsulates the Self\-Consistency pattern\(Wanget al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib44)\)\(parallel generation with majority voting\), directly derived from one of our experimental baselines \(CoT SC in Table[A1](https://arxiv.org/html/2606.30704#A1.T1)\)\. Critically, incorporating this operator requires no model retraining, only defining its natural language interface following the format described in Listing[5](https://arxiv.org/html/2606.30704#LST5)\.
To demonstrate immediate operator utilization, we generate workflows for GSM8K mathematical reasoning after integratingSelfConsistency\. Listing[13](https://arxiv.org/html/2606.30704#LST13)shows an example generated workflow that successfully invokes the newly integrated operator with parallel sampling \(n=5\) and similarity\-based voting, demonstrating thatMetaFlowcan immediately compose effective workflows with novel operators through single\-inference generation without any retraining\.
Implications\.This validatesMetaFlow’slow\-cost continuous extensibility: \(1\)Minimal integration cost: introducing a new operator requires only defining its interface, without model retraining or iterative search \(hours for MCTS/evolutionary methods vs\. minutes forMetaFlow\); \(2\)Rapid abstraction of proven patterns: practitioners can quickly encapsulate manually\-tested workflow logic discovered through experimentation into reusable operators; \(3\)Immediate high\-quality generation: generating effective workflows with the new operator costs merely a single inference; \(4\)Scalable library growth: each new operator becomes immediately available across all tasks without proportional computational overhead, enabling continuous knowledge accumulation\. This paradigm transforms workflow optimization from isolated task\-specific searches into a scalable knowledge base where proven patterns become reusable primitives\.
### 5\.3Zero\-Shot Generalization to Novel Operators
To validate true out\-of\-distribution \(OOD\) generalization, we evaluateMetaFlowon HotpotQA\(Yanget al\.,[2018](https://arxiv.org/html/2606.30704#bib.bib13)\)multi\-hop question answering with theVectorSearchoperator \(Listing[3](https://arxiv.org/html/2606.30704#LST3)\) entirely unseen during training\. This tests two critical OOD dimensions: \(1\)domain shiftfrom math/code reasoning to retrieval\-based QA, and \(2\)novel operatorrequiring hybrid document and sentence\-level vector search\. We generate 100 candidate workflows with𝖮𝗉𝗌=\{Generate,Summarize,Revise,Ensemble,VectorSearch\}\\displaystyle\\mathsf\{Ops\}=\\\{\\texttt\{Generate\},\\texttt\{Summarize\},\\texttt\{Revise\},\\texttt\{Ensemble\},\\texttt\{VectorSearch\}\\\}evaluated on 100 HotpotQA instances \(Validation\), compared against a CoT\+RAG baseline using the same API \(Qwen\-Turbo\)\.



Figure 4:Zero\-shot generalization with novelVectorSearchoperator on HotpotQA\.Left:Individual workflow performance across 100 generations shows high variance, 31 workflows fail completely while the best achieves0\.74\\displaystyle 0\.74accuracy\.Middle:Average score converges to0\.29\\displaystyle 0\.29, reflecting the exploration cost of zero\-shot generation\.Right:Best\-of\-k\\displaystyle kscore reaches0\.74\\displaystyle 0\.74\(60\.9% above baseline 0\.46\), surpassing baseline atk=76\\displaystyle k=76\.Figure[4](https://arxiv.org/html/2606.30704#S5.F4)reveals the characteristics of zero\-shot workflow generation\. Theleft panelshows substantial performance variance: while 31% of workflows fail \(score=0\.0, likely due to syntax errors or incorrect operator usage\), successful workflows demonstrate strong performance, with the best achieving0\.74\\displaystyle 0\.74accuracy\. Themiddle paneltracks the average score across generated workflows, which converges to0\.29\\displaystyle 0\.29, below the0\.46\\displaystyle 0\.46baseline due to the high failure rate inherent in zero\-shot generation\. However, theright paneldemonstrates that the best\-of\-k\\displaystyle kselection strategy efficiently identifies high\-quality solutions: the best score monotonically increases, surpassing the baseline atk=76\\displaystyle k=76workflows and reaching0\.74\\displaystyle 0\.74\(60\.9% improvement\) with the test set \(another100\\displaystyle 100instances\) with the same trend of performance\. This validates that moderate sampling suffices to discover effective workflows despite zero\-shot exploration risks\. The highest\-scoring workflow \(Listing[14](https://arxiv.org/html/2606.30704#LST14)in Appendix[G](https://arxiv.org/html/2606.30704#A7)\) implements sophisticated multi\-hop reasoning through iterative retrieval\-generation cycles—extracting entities, performing two\-stage document search with connection analysis, and synthesizing information across retrieved contexts—demonstratingMetaFlow’s ability to compose complex operator sequences for unseen tools\. The results confirm our meta\-learning approach: train once on diverse tasks, then rapidly adapt to new operators and domains without re\-optimization\.
### 5\.4Main Results and Analysis
Experimental Setup\.We evaluateMetaFlowon benchmarks spanning question answering \(HotpotQA, DROP: 1,000 instances each\), code generation \(MBPP, HumanEval: full sets\), and mathematical reasoning \(GSM8K: 1,000 instances, MATH: Level\-5 problems\), following ScoreFlow’s configuration with 1:4 train\-test splits\. We compare against two baseline categories: \(1\)manually designed workflows—IO, CoT\(Weiet al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib43)\), CoT SC\(Wanget al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib44)\), MedPrompt\(Noriet al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib45)\), MultiPersona\(Wanget al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib46)\), Self\-Refine\(Madaanet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib47)\); \(2\)automatically optimized workflows—ADAS\(Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30)\), AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\), ScoreFlow\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\)\. The PlannerQwen3\-8Buses base operators \{Generate,Summarize,Revise,Ensemble\} with dynamic prompt rewriting, plus novel operators \{Decompose,Programmer\} for OOD testing \(natural language descriptions provided at inference\)\. For each task, we generate 20 candidate workflows, validate on 50 instances, and select the best for testing\. All methods useGPT\-4o\-mini\-0718as executor and judge\. Workflow execution is orchestrated by MetaGPT\.
Performance Analysis\.Table[A1](https://arxiv.org/html/2606.30704#A1.T1)in Appendix[A](https://arxiv.org/html/2606.30704#A1)showsMetaFlowachieves 78\.8 average accuracy, competitive with ScoreFlow \(82\.5\), AFlow \(78\.3\), and ADAS \(73\.1\) while requiring only single\-inference generation versus their resource\-intensive per\-instance optimization\. Notably,MetaFlowmatches or exceeds manually designed workflows and surpasses many automated methods on individual tasks \(e\.g\., GSM8K: 93\.8\)\. The framework demonstrates strong performance across diverse domains—mathematical reasoning \(GSM8K, MATH\), reading comprehension \(DROP\), and code generation \(MBPP\)—validating our meta\-learning approach’s cross\-task generalization\. All baseline scores are from ScoreFlow\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\)\. And FlowReasoner\(Gaoet al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib32)\)achieves82\.19\\displaystyle 82\.19on MBPP withGPT\-4o\-mini\-0718as executor\.
Understanding the Performance Gap: Paradigm Differences and Trade\-offs\.Our average performance \(78\.8\) trails ScoreFlow \(82\.5\) by 3\.7 points, which reflects fundamental differences in problem formulation rather than algorithmic limitations\. This gap stems from three interacting factors\.First, risk amplification from task\-level generation:As a cross\-task generator,MetaFlowproduces one workflow𝖶C\\displaystyle\\mathsf\{W\}\_\{C\}per task—any syntax error or malformed operator call yields zero accuracy across all test instances\. In contrast, ScoreFlow’s instance\-level approach generates𝖶p\\displaystyle\\mathsf\{W\}\_\{p\}per problem—a failed generation affects only one data point\. This risk materializes in our VectorSearch experiments \(Figure[4](https://arxiv.org/html/2606.30704#S5.F4)left\): 31% of generated workflows fail to execute, directly penalizing task\-level metrics\.Second, the complexity\-performance trade\-off:While simple workflows dominate on tasks solvable by direct reasoning, this advantage inverts for complex tool integration scenarios\. On HotpotQA with the novelVectorSearchoperator \(Section[5\.3](https://arxiv.org/html/2606.30704#S5.SS3)\), the simple CoT\+RAG baseline achieves 0\.46 accuracy\. MetaFlow’s best workflow—requiring sophisticated orchestration of retrieval, decomposition, and reasoning operators—reaches 0\.74 \(\+60\.9%improvement\), demonstrating that complex operator composition becomes essential when tool complexity increases\. Critically, even with best\-of\-20 validation selection, our total cost remains orders of magnitude lower than iterative search methods: 20 generations yield a reusable task\-level workflow versus thousands of MCTS evaluations \(AFlow\) orN\\displaystyle Nper\-instance generations \(ScoreFlow\)\. Figure[4](https://arxiv.org/html/2606.30704#S5.F4)\(right\) shows best\-of\-k\\displaystyle kscaling stabilizes aroundk≈80\\displaystyle k\\approx 80, where marginal sampling cost \(<$1\\displaystyle<\\mathdollar 1withQwen3\-8B\) far outweighs other automatically designed workflows baselines\.
## 6Conclusion
We introduce MetaFlow, a meta\-learning framework that trains language models to generate task\-level workflows through a two\-stage paradigm combining supervised fine\-tuning with reinforcement learning across diverse task\-operator combinations\. Across benchmarks in question answering, code generation, and mathematical reasoning, MetaFlow achieves competitive performance \(78\.8 average accuracy\) with single\-inference generation, while demonstrating strong zero\-shot generalization to novel operators and domains\. The observed 31% syntax error rate in zero\-shot generation highlights a key limitation of single\-inference approaches—future work could explore multi\-turn reinforcement learning where the model iteratively refines workflows through interaction with execution feedback, potentially combining the efficiency of learned meta\-strategies with the robustness of adaptive generation\.
## Acknowledgements
This work was supported by the National Natural Science Foundation of China \(Grant No\. 625B1012\)\.
## References
- J\. Austin, A\. Odena, M\. Nye, M\. Bosma, H\. Michalewski, D\. Dohan, E\. Jiang, C\. Cai, M\. Terry, Q\. Le,et al\.\(2021\)Program synthesis with large language models\.arXiv preprint arXiv:2108\.07732\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- G\. Chen, S\. Dong, Y\. Shu, G\. Zhang, J\. Sesay, B\. F\. Karlsson, J\. Fu, and Y\. Shi \(2023\)Autoagents: a framework for automatic agent generation\.arXiv preprint arXiv:2309\.17288\.Cited by:[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p1.1)\.
- M\. Chen, J\. Tworek, H\. Jun, Q\. Yuan, H\. P\. de Oliveira Pinto, J\. Kaplan, H\. Edwards, Y\. Burda, N\. Joseph, G\. Brockman, A\. Ray, R\. Puri, G\. Krueger, M\. Petrov, H\. Khlaaf, G\. Sastry, P\. Mishkin, B\. Chan, S\. Gray, N\. Ryder, M\. Pavlov, A\. Power, L\. Kaiser, M\. Bavarian, C\. Winter, P\. Tillet, F\. P\. Such, D\. Cummings, M\. Plappert, F\. Chantzis, E\. Barnes, A\. Herbert\-Voss, W\. H\. Guss, A\. Nichol, A\. Paino, N\. Tezak, J\. Tang, I\. Babuschkin, S\. Balaji, S\. Jain, W\. Saunders, C\. Hesse, A\. N\. Carr, J\. Leike, J\. Achiam, V\. Misra, E\. Morikawa, A\. Radford, M\. Knight, M\. Brundage, M\. Murati, K\. Mayer, P\. Welinder, B\. McGrew, D\. Amodei, S\. McCandlish, I\. Sutskever, and W\. Zaremba \(2021\)Evaluating large language models trained on code\.CoRRabs/2107\.03374\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- K\. Cobbe, V\. Kosaraju, M\. Bavarian, M\. Chen, H\. Jun, L\. Kaiser, M\. Plappert, J\. Tworek, J\. Hilton, R\. Nakano, C\. Hesse, and J\. Schulman \(2021\)Training verifiers to solve math word problems\.arXiv preprint arXiv:2110\.14168\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- H\. Ding, Y\. Fang, R\. Zhu, X\. Jiang, J\. Zhang, Y\. Xu, X\. Chu, J\. Zhao, and Y\. Wang \(2024\)3DS: decomposed difficulty data selection’s case study on llm medical domain adaptation\.arXiv preprint arXiv:2410\.10901\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- D\. Dua, Y\. Wang, P\. Dasigi, G\. Stanovsky, S\. Singh, and M\. Gardner \(2019\)DROP: A reading comprehension benchmark requiring discrete reasoning over paragraphs\.InNAACL\-HLT \(1\),pp\. 2368–2378\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- C\. Finn, P\. Abbeel, and S\. Levine \(2017\)Model\-agnostic meta\-learning for fast adaptation of deep networks\.InProceedings of the 34th International Conference on Machine Learning,pp\. 1126–1135\.Cited by:[§3](https://arxiv.org/html/2606.30704#S3.p1.1),[§3](https://arxiv.org/html/2606.30704#S3.p3.1)\.
- L\. Franceschi, P\. Frasconi, S\. Salzo, R\. Grazzi, and M\. Pontil \(2018\)Bilevel programming for hyperparameter optimization and meta\-learning\.InProceedings of the 35th International Conference on Machine Learning,pp\. 1568–1577\.Cited by:[§3](https://arxiv.org/html/2606.30704#S3.p1.1),[§3](https://arxiv.org/html/2606.30704#S3.p4.3)\.
- H\. Gao, Y\. Liu, Y\. He, L\. Dou, C\. Du, Z\. Deng, B\. Hooi, M\. Lin, and T\. Pang \(2025\)Flowreasoner: reinforcing query\-level meta\-agents\.arXiv preprint arXiv:2504\.15257\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p3.1),[§1](https://arxiv.org/html/2606.30704#S1.p5.1),[§1](https://arxiv.org/html/2606.30704#S1.p8.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p2.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p2.1)\.
- Q\. Guo, R\. Wang, J\. Guo, B\. Li, K\. Song, X\. Tan, G\. Liu, J\. Bian, and Y\. Yang \(2023\)Connecting large language models with evolutionary algorithms yields powerful prompt optimizers\.arXiv preprint arXiv:2309\.08532\.Cited by:[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p1.1)\.
- I\. Hong, Z\. Li, A\. Bukharin, Y\. Li, H\. Jiang, T\. Yang, and T\. Zhao \(2024\)Adaptive preference scaling for reinforcement learning with human feedback\.Advances in Neural Information Processing Systems37,pp\. 107249–107269\.Cited by:[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- S\. Hong, X\. Zheng, J\. Chen, Y\. Cheng, J\. Wang, C\. Zhang, Z\. Wang, S\. K\. S\. Zhang, Z\. Gui,et al\.\(2023\)MetaGPT: meta programming for a multi\-agent collaborative framework\.arXiv preprint arXiv:2308\.00352\.Cited by:[§4\.1](https://arxiv.org/html/2606.30704#S4.SS1.p1.2),[§4\.1](https://arxiv.org/html/2606.30704#S4.SS1.p2.1),[§4\.1](https://arxiv.org/html/2606.30704#S4.SS1.p4.7)\.
- E\. J\. Hu, Y\. Shen, P\. Wallis, Z\. Allen\-Zhu, Y\. Li, S\. Wang, L\. Wang, W\. Chen,et al\.\(2022\)Lora: low\-rank adaptation of large language models\.\.ICLR1\(2\),pp\. 3\.Cited by:[§C\.2](https://arxiv.org/html/2606.30704#A3.SS2.p1.2),[§5\.1](https://arxiv.org/html/2606.30704#S5.SS1.p1.7)\.
- S\. Hu, C\. Lu, and J\. Clune \(2024\)Automated design of agentic systems\.arXiv preprint arXiv:2408\.08435\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.8.1),[§1](https://arxiv.org/html/2606.30704#S1.p3.1),[§1](https://arxiv.org/html/2606.30704#S1.p4.1),[§1](https://arxiv.org/html/2606.30704#S1.p8.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p2.1),[§5\.2](https://arxiv.org/html/2606.30704#S5.SS2.p1.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1)\.
- B\. Jiang, R\. Zhu, J\. Wu, Z\. Jiang, Y\. He, J\. Gao, J\. Yu, R\. Min, Y\. Wang, H\. Yang,et al\.\(2025\)Evaluating large language model with knowledge oriented language specific simple question answering\.arXiv preprint arXiv:2505\.16591\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- O\. Khattab, B\. V\. Akula,et al\.\(2023\)DsPy: expressive, modular prompting for language models\.arXiv preprint arXiv:2310\.01348\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p2.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p1.1)\.
- J\. P\. C\. Kleijnen \(1975\)Antithetic variates, common random numbers and optimal computer time allocation in simulation\.Management Science21\(10\),pp\. 1176–1185\.Cited by:[§4\.2\.2](https://arxiv.org/html/2606.30704#S4.SS2.SSS2.p5.4)\.
- C\. Li, Z\. Wang, D\. Zhang, X\. Zhao, C\. Wang, X\. Wang, Y\. Wang, H\. Zhang, and W\. Zhu \(2025\)ScoreFlow: mastering llm agent workflows via score\-based preference optimization\.arXiv preprint arXiv:2502\.04306\.Cited by:[§3](https://arxiv.org/html/2606.30704#S3.p1.1)\.
- Z\. Li, S\. Xu, K\. Mei, W\. Hua, B\. Rama, O\. Raheja, H\. Wang, H\. Zhu, and Y\. Zhang \(2024\)Autoflow: automated workflow generation for large language model agents\.arXiv preprint arXiv:2407\.12821\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p2.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p1.1)\.
- Z\. Liu, Y\. Zhang, P\. Li, Y\. Liu, and D\. Yang \(2024\)A dynamic llm\-powered agent network for task\-oriented agent collaboration\.InFirst Conference on Language Modeling,Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p2.1)\.
- A\. Madaan, N\. Tandon, P\. Gupta, S\. Hallinan, L\. Gao, S\. Wiegreffe, U\. Alon, N\. Dziri, S\. Prabhumoye, Y\. Yang,et al\.\(2024\)Self\-refine: iterative refinement with self\-feedback\.Advances in Neural Information Processing Systems36\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.7.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1)\.
- H\. Nori, Y\. T\. Lee, S\. Zhang, D\. Carignan, R\. Edgar, N\. Fusi, N\. King, J\. Larson, Y\. Li, W\. Liu,et al\.\(2023\)Can generalist foundation models outcompete special\-purpose tuning? case study in medicine\.arXiv preprint arXiv:2311\.16452\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.5.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1)\.
- OpenAI \(2023\)AIME benchmark for mathematical reasoning\.https://openai\.com/research\.Note:Accessed 2024Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- Z\. Shao, P\. Yuan, H\. Li, Y\. Wang, Y\. Xu, X\. Sun, K\. Liu, Y\. Lin, C\. Yue, K\. Chen,et al\.\(2024\)DeepSeekMath: pushing the limits of mathematical reasoning in open language models\.arXiv preprint arXiv:2402\.03300\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p8.1),[§4\.2\.2](https://arxiv.org/html/2606.30704#S4.SS2.SSS2.p3.5)\.
- L\. Song, J\. Liu, J\. Zhang, S\. Zhang, A\. Luo, S\. Wang, Q\. Wu, and C\. Wang \(2024\)Adaptive in\-conversation team building for language model agents\.arXiv preprint arXiv:2405\.19425\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p2.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p1.1)\.
- Q\. Team \(2024\)Qwen2 technical report\.arXiv preprint arXiv:2407\.106712\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p8.1)\.
- X\. Wang, J\. Wei, D\. Schuurmans, Q\. Le, E\. Chi, S\. Narang, A\. Chowdhery, and D\. Zhou \(2022\)Self\-consistency improves chain of thought reasoning in language models\.The Eleventh International Conference on Learning Representations\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.4.1),[§B\.1](https://arxiv.org/html/2606.30704#A2.SS1.p3.1),[Listing 2](https://arxiv.org/html/2606.30704#LST2),[§5\.2](https://arxiv.org/html/2606.30704#S5.SS2.p1.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1)\.
- Y\. Wang, L\. Yang, G\. Li, M\. Wang, and B\. Aragam \(2025\)ScoreFlow: mastering llm agent workflows via score\-based preference optimization\.arXiv preprint arXiv:2502\.04306\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.10.1),[§1](https://arxiv.org/html/2606.30704#S1.p3.1),[§1](https://arxiv.org/html/2606.30704#S1.p4.1),[§1](https://arxiv.org/html/2606.30704#S1.p5.1),[§1](https://arxiv.org/html/2606.30704#S1.p8.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p1.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p2.1),[1st item](https://arxiv.org/html/2606.30704#S3.I3.i1.p1.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p2.1)\.
- Z\. Wang, S\. Mao, W\. Wu, T\. Ge, F\. Wei, and H\. Ji \(2024\)Unleashing the emergent cognitive synergy in large language models: a task\-solving agent through multi\-persona self\-collaboration\.InProceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies \(Volume 1: Long Papers\),pp\. 257–279\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.6.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1)\.
- J\. Wei, X\. Wang, D\. Schuurmans, M\. Bosma, F\. Xia, E\. Chi, Q\. V\. Le, D\. Zhou,et al\.\(2022\)Chain\-of\-thought prompting elicits reasoning in large language models\.Advances in neural information processing systems35,pp\. 24824–24837\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.3.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1)\.
- Z\. Xu, Y\. Wang, X\. Yang, L\. Wang, W\. Luo, K\. Zhang, B\. Hu, and M\. Zhang \(2025\)ComfyUI\-r1: exploring reasoning models for workflow generation\.arXiv preprint arXiv:2506\.09790\.Cited by:[1st item](https://arxiv.org/html/2606.30704#S3.I3.i1.p1.1),[§3](https://arxiv.org/html/2606.30704#S3.p1.1)\.
- A\. Yang, A\. Li, B\. Yang, B\. Zhang, B\. Hui, B\. Zheng, B\. Yu, C\. Gao, C\. Huang, C\. Lv,et al\.\(2025\)Qwen3 technical report\.arXiv preprint arXiv:2505\.09388\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p8.1)\.
- Z\. Yang, P\. Qi, S\. Zhang, Y\. Bengio, W\. W\. Cohen, R\. Salakhutdinov, and C\. D\. Manning \(2018\)HotpotQA: a dataset for diverse, explainable multi\-hop question answering\.arXiv preprint arXiv:1809\.09600\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1),[§5\.3](https://arxiv.org/html/2606.30704#S5.SS3.p1.1)\.
- G\. Zhang, Y\. Yue, X\. Sun, G\. Wan, M\. Yu, J\. Fang, K\. Wang, T\. Chen, and D\. Cheng \(2024a\)G\-designer: architecting multi\-agent communication topologies via graph neural networks\.arXiv preprint arXiv:2410\.11782\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p2.1)\.
- J\. Zhang, Y\. Xiang, C\. Wang, A\. Zhou, J\. Lu, D\. Chen, C\. He, Y\. Wang, B\. Ding, D\. Gao,et al\.\(2024b\)AFlow: automating agentic workflow generation\.arXiv preprint arXiv:2410\.10762\.Cited by:[Table A1](https://arxiv.org/html/2606.30704#A1.T1.3.9.1),[§B\.1](https://arxiv.org/html/2606.30704#A2.SS1.p1.1),[§1](https://arxiv.org/html/2606.30704#S1.p3.1),[§1](https://arxiv.org/html/2606.30704#S1.p4.1),[§1](https://arxiv.org/html/2606.30704#S1.p8.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p1.1),[§2\.2](https://arxiv.org/html/2606.30704#S2.SS2.p2.1),[3rd item](https://arxiv.org/html/2606.30704#S3.I1.i3.p1.1),[2nd item](https://arxiv.org/html/2606.30704#S3.I3.i2.p1.1),[§4\.1](https://arxiv.org/html/2606.30704#S4.SS1.p2.1),[§5\.2](https://arxiv.org/html/2606.30704#S5.SS2.p1.1),[§5\.4](https://arxiv.org/html/2606.30704#S5.SS4.p1.1)\.
- Z\. Zhuet al\.\(2024\)OlympiadBench: a benchmark for mathematical reasoning at the olympiad level\.arXiv preprint arXiv:2402\.00000\.Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p1.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
- M\. Zhuge, W\. Wang, L\. Kirsch, F\. Faccio, D\. Khizbullin, and J\. Schmidhuber \(2024\)Gptswarm: language agents as optimizable graphs\.InForty\-first International Conference on Machine Learning,Cited by:[§1](https://arxiv.org/html/2606.30704#S1.p2.1),[§2\.1](https://arxiv.org/html/2606.30704#S2.SS1.p1.1)\.
## Appendix AMain Results
Table A1:Performance comparison across multiple benchmarks\.MetaFlowachieves 78\.8 average score with single\-inference generation, demonstrating competitive performance and strong cross\-domain generalization\.MethodDROPMBPPGSM8KMATHAvgIO81\.669\.589\.152\.273\.1CoT\(Weiet al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib43)\)83\.270\.488\.353\.473\.8CoT SC\(Wanget al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib44)\)83\.271\.388\.653\.874\.2MedPrompt\(Noriet al\.,[2023](https://arxiv.org/html/2606.30704#bib.bib45)\)83\.069\.288\.153\.773\.5MultiPersona\(Wanget al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib46)\)81\.370\.489\.851\.973\.4Self Refine\(Madaanet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib47)\)82\.570\.087\.550\.072\.5ADAS\(Huet al\.,[2024](https://arxiv.org/html/2606.30704#bib.bib30)\)81\.368\.790\.551\.773\.1AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\)83\.582\.990\.855\.878\.3ScoreFlow\(Wanget al\.,[2025](https://arxiv.org/html/2606.30704#bib.bib27)\)86\.284\.794\.664\.482\.5Ours82\.877\.593\.861\.078\.8
## Appendix BMetaflow Architecture
### B\.1Operators Design
For the basic operators defined in the left part of Figure[2](https://arxiv.org/html/2606.30704#S4.F2), their implementations are identical to those in the AFlow\(Zhanget al\.,[2024b](https://arxiv.org/html/2606.30704#bib.bib4)\)codebase, and thus we omit their detailed descriptions here\. In the following, we introduce the newly defined operators that we have designed for this work\.
Decompose Operator: Beyond the basic text\-processing operators, we introduce theDecomposeoperator to handle complex problem\-solving scenarios that require hierarchical decomposition\. This operator breaks down intricate problems into structured subproblems with explicit dependency relationships, enabling workflows to tackle multi\-step reasoning tasks systematically\. The operator is invoked as:await self\.decompose\(instruction: str, context: str\)and returns a list of subproblem dictionaries, each containing an ID, description, and dependencies\. The following code block shows the implementation details of this operator\.
classDecompose\(Operator\):
"""
CoreOperator:Decompose
Breaksdowncomplexproblemsintomanageablesubproblems\.
"""
asyncdef\_\_call\_\_\(self,instruction:str="",context:str=""\)\-\>List\[Dict\[str,str\]\]:
prompt=f"""Youareanexpertatproblemdecomposition\.Breakdownthecomplexproblemintomanageablesubproblems\.
\*\*Instructionondecompositionstrategy:\*\*
\{instruction\}
\*\*Problem/ContexttoDecompose:\*\*
\{contextifcontextelse"Nocontextprovided\."\}
\*\*OriginalProblem:\*\*
\{self\.problem\_text\}
YourresponseMUSTbevalidXMLwith’think’and’subproblems’fields\.
\-In"think",explainyourdecompositionstrategy
\-In"subproblems",providealistwhereeachitemhas:
\-id:uniqueidentifier\(e\.g\.,"sub1","sub2"\)
\-description:cleardescriptionofthesubproblem
\-dependencies:comma\-separatedIDsofprerequisitesubproblems\(emptyifnone\)
\*\*EXAMPLE:\*\*
<think\>Thisproblemrequiresfindingareathenvolume\.</think\>
<subproblems\>
\[
\{\{"id":"sub1","description":"Calculatetheradius","dependencies":""\}\},
\{\{"id":"sub2","description":"Calculatethearea","dependencies":"sub1"\}\},
\{\{"id":"sub3","description":"Calculatethevolume","dependencies":"sub2"\}\}
\]
</subproblems\>"""
response=awaitself\.\_fill\_node\(DecomposeOp,prompt,mode="xml\_fill"\)
response=DecomposeOp\(\*\*response\)
return\[sub\.dict\(\)forsubinresponse\.subproblems\]
Listing 1:Implementation of theDecomposeoperator for hierarchical problem decomposition\.SelfConsistency Operator: To demonstrateMetaFlow’s capability for low\-cost operator integration and continuous library expansion \(Section[5\.2](https://arxiv.org/html/2606.30704#S5.SS2)\), we introduce theSelfConsistencyoperator—a practical abstraction of the Self\-Consistency reasoning pattern\(Wanget al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib44)\)\. This operator encapsulates the parallel generation with majority voting strategy, which was originally one of our experimental baselines \(CoT SC in Table[A1](https://arxiv.org/html/2606.30704#A1.T1)\)\. Critically, incorporating this operator intoMetaFlowrequiresno model retraining; the planner learns to effectively utilize it through its natural language interface description alone\. The following code block presents the complete implementation:
classSelfConsistency\(Operator\):
"""Self\-Consistency:multi\-pathsampling\+majorityvotingforbetterreasoning\."""
def\_\_init\_\_\(self,llm,problem\_text:str="",n\_samples:int=5,
similarity\_threshold:float=0\.85,return\_full\_info:bool=False\):
super\(\)\.\_\_init\_\_\(llm,problem\_text\)
self\.n\_samples=n\_samples
self\.similarity\_threshold=similarity\_threshold
self\.return\_full\_info=return\_full\_info
asyncdef\_\_call\_\_\(self,instruction:str="",context:str="",answer\_type:str="auto"\)\-\>str:
silent=os\.environ\.get\(’SCOREFLOW\_SILENT’,’false’\)\.lower\(\)==’true’
ifnotsilent:
print\(f"\[SelfConsistency\]samples=\{self\.n\_samples\},threshold=\{self\.similarity\_threshold\}"\)
paths=awaitself\.\_parallel\_sampling\(instruction,context\)
ifnotsilent:
print\(f"Generated\{len\(paths\)\}paths"\)
raw\_answers=awaitself\.\_extract\_answers\_batch\(paths,answer\_type\)
ifnotsilent:
print\(f"Extracted\{len\(\[aforainraw\_answersifa\]\)\}answers"\)
normalized=\[self\.\_normalize\_answer\(a,answer\_type\)forainraw\_answers\]
clustered=self\.\_cluster\_similar\_answers\(normalized\)
votes=Counter\(clustered\)
ifnotvotes:
ifnotsilent:
print\("Novalidanswers,fallback"\)
returnawaitself\.\_fallback\_generate\(instruction,context\)
answer,count=votes\.most\_common\(1\)\[0\]
conf=count/len\(clustered\)ifclusteredelse0
ifnotsilent:
print\(f"Votes:\{dict\(votes\)\}\|Answer:\{answer\}\|Conf:\{conf:\.1%\}"\)
ifself\.return\_full\_info:
returnself\.\_format\_full\_response\(paths,raw\_answers,votes,answer,conf\)
returnanswer
asyncdef\_parallel\_sampling\(self,instruction:str,context:str\)\-\>List\[str\]:
prompt=f"""Solvestepbystep\.
\*\*Problem:\*\*\{self\.problem\_text\}
\*\*Instruction:\*\*\{instructionor"Solvecarefully\."\}
\*\*Context:\*\*\{contextor"None"\}
Showreasoning\.Endwith"FinalAnswer:"or"Theansweris:"
\*\*Solution:\*\*"""
tasks=\[self\.\_sample\_single\_path\(prompt\)for\_inrange\(self\.n\_samples\)\]
results=awaitasyncio\.gather\(\*tasks,return\_exceptions=True\)
return\[rforrinresultsifisinstance\(r,str\)andlen\(r\.strip\(\)\)\>10\]
asyncdef\_sample\_single\_path\(self,prompt:str\)\-\>str:
try:
return\(awaitself\.\_fill\_node\(GenerateOp,prompt,mode="single\_fill"\)\)\.get\("response",""\)
except:
return""
asyncdef\_extract\_answers\_batch\(self,paths:List\[str\],answer\_type:str\)\-\>List\[str\]:
answers=\[\]
forpinpaths:
ans=self\.\_rule\_based\_extraction\(p,answer\_type\)
answers\.append\(ansifanselseawaitself\.\_llm\_extract\_answer\(p,answer\_type\)\)
returnanswers
def\_rule\_based\_extraction\(self,text:str,answer\_type:str\)\-\>str:
patterns=\[
r"\(?:finalanswer\|theansweris\|answer:\)\\s\*\[:\\s\]\*\(\.\+?\)\(?:\\n\|$\|\\\.\(?:\\s\|$\)\)",
r"\(?:therefore\|thus\|so\|hence\),?\\s\*\(?:theansweris\)?\\s\*\[:\\s\]\*\(\.\+?\)\(?:\\n\|$\|\\\.\(?:\\s\|$\)\)",
r"\\\\boxed\\\{\(\.\+?\)\\\}",r"\\\*\\\*\(\.\+?\)\\\*\\\*\\s\*$",
\]
forpinpatterns:
m=re\.search\(p,text\.lower\(\),re\.IGNORECASE\|re\.MULTILINE\)
ifm:
ans=re\.sub\(r’^\[:\\s\]\+\|\[:\\s\\\.\]\+$’,’’,m\.group\(1\)\.strip\(\)\)
ifansandlen\(ans\)<200:
returnans
ifanswer\_type=="choice":
m=re\.search\(r"\(?:answer\|option\|choice\)\[:\\s\]\*\(\[A\-Da\-d\]\)\\b",text,re\.IGNORECASE\)
ifm:returnm\.group\(1\)\.upper\(\)
ifanswer\_type=="numeric":
nums=re\.findall\(r’\-?\\d\+\(?:\\\.\\d\+\)?\(?:/\\d\+\)?’,text\)
ifnums:returnnums\[\-1\]
return""
asyncdef\_llm\_extract\_answer\(self,path:str,answer\_type:str\)\-\>str:
hints=\{"numeric":"numberonly","choice":"letteronly","short":"brief","boolean":"yes/noonly"\}
prompt=f"Extractfinalanswer\.\{hints\.get\(answer\_type,’’\)\}ReturnONLYtheanswer\.\\n\*\*Solution:\*\*\{path\[\-2000:\]\}\\n\*\*Answer:\*\*"
try:
ans=\(awaitself\.\_fill\_node\(GenerateOp,prompt,mode="single\_fill"\)\)\.get\("response",""\)\.strip\(\)
returnre\.sub\(r’^\(theansweris\|answer:\|finalanswer:\)\\s\*’,’’,ans,flags=re\.IGNORECASE\)\.strip\(\)
except:
return""
def\_normalize\_answer\(self,answer:str,answer\_type:str\)\-\>str:
ifnotanswer:return""
n=re\.sub\(r’^\(the\|a\|an\)’,’’,answer\.strip\(\)\.lower\(\)\)
n=re\.sub\(r’\[\.,\!?;:\]\+$’,’’,n\)
ifanswer\_type=="numeric"orre\.match\(r’^\-?\\d’,n\):
n=re\.sub\(r’\[$%,\\s\]’,’’,n\)
if’/’inn:
try:p=n\.split\(’/’\);n=str\(float\(p\[0\]\)/float\(p\[1\]\)\)iflen\(p\)==2elsen
except:pass
elifanswer\_type=="choice":
m=re\.search\(r’\[A\-Da\-d\]’,n\)
ifm:n=m\.group\(0\)\.upper\(\)
elifanswer\_type=="boolean":
n=’yes’ifnin\[’yes’,’true’,’1’,’correct’,’right’\]else\(’no’ifnin\[’no’,’false’,’0’,’incorrect’,’wrong’\]elsen\)
returnn
def\_cluster\_similar\_answers\(self,answers:List\[str\]\)\-\>List\[str\]:
valid=\[aforainanswersifa\]
ifnotvalidorself\.similarity\_threshold\>=1\.0:returnvalid
clusters=\[\]
foransinvalid:
matched=False
forrep,membersinclusters:
ifSequenceMatcher\(None,ans,rep\)\.ratio\(\)\>=self\.similarity\_threshold:
members\.append\(ans\);matched=True;break
ifnotmatched:clusters\.append\(\(ans,\[ans\]\)\)
return\[Counter\(m\)\.most\_common\(1\)\[0\]\[0\]forainvalidforr,minclustersifainm\]
asyncdef\_fallback\_generate\(self,instruction:str,context:str\)\-\>str:
prompt=f"Solve:\{self\.problem\_text\}\\nInstruction:\{instruction\}\\nContext:\{contextor’None’\}"
return\(awaitself\.\_fill\_node\(GenerateOp,prompt,mode="single\_fill"\)\)\.get\("response","Noanswer"\)
def\_format\_full\_response\(self,paths:List\[str\],raw:List\[str\],votes:Counter,answer:str,conf:float\)\-\>str:
lines=\[f"\#\#Self\-ConsistencyResult",f"\*\*FinalAnswer:\*\*\{answer\}",f"\*\*Confidence:\*\*\{conf:\.1%\}",
"\#\#\#Votes"\]\+\[f"\-\{a\}:\{c\}"fora,cinvotes\.most\_common\(\)\]
return"\\n"\.join\(lines\)
Listing 2:Implementation of theSelfConsistencyoperator, which abstracts the Self\-Consistency pattern\(Wanget al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib44)\)into a reusable component\. This operator performs parallel sampling of multiple reasoning paths \(defaultn=5\\displaystyle n=5\) and applies majority voting with similarity\-based answer clustering to select the most consistent solution\. The implementation demonstratesMetaFlow’s low\-cost extensibility: practitioners can encapsulate manually\-tested reasoning patterns into operators without model retraining\.VectorSearch Operator: To evaluate the generalization capability ofMetaFlowto completely out\-of\-distribution \(OOD\) operators, we introduce theVectorSearchoperator[3](https://arxiv.org/html/2606.30704#LST3), which is a complex tool\-calling operator that was entirely unseen during both the SFT and RLVR training phases\. Unlike the basic text\-processing operators used in training,VectorSearchrequires sophisticated external API interactions with a vector database \(ChromaDB\) and involves multiple parameters for controlling retrieval behavior\. The operator is invoked as:await self\.vector\_search\(instruction: str, context: str, top\_k: int\), where it performs hybrid retrieval combining document\-level and sentence\-level semantic search over the HotpotQA knowledge base\. Despite its complexity and complete absence from training data,MetaFlowsuccessfully learns to incorporate this operator into generated workflows based solely on its natural language description provided at inference time, as demonstrated in Appendix[G](https://arxiv.org/html/2606.30704#A7)\.
classVectorSearch\(Operator\):
"""
CoreOperator:VectorSearch
RetrievesrelevantdocumentsfromHotpotQAvectordatabaseusingRAGsystem\.
"""
def\_\_init\_\_\(self,llm,problem\_text:str="",db\_config:Dict=None\):
super\(\)\.\_\_init\_\_\(llm,problem\_text\)
self\.config=self\.\_load\_config\(\)
ifdb\_config:
self\.config\.update\(db\_config\)
self\.\_init\_chromadb\(\)
def\_load\_config\(self\)\-\>Dict:
"""Loadconfigurationfromdb\.configfile"""
frompathlibimportPath
config=\{\}
config\_file=Path\(\_\_file\_\_\)\.parent/"db\.config"
ifconfig\_file\.exists\(\):
withopen\(config\_file,’r’\)asf:
forlineinf:
line=line\.strip\(\)
iflineandnotline\.startswith\(’\#’\)and’=’inline:
key,value=line\.split\(’=’,1\)
key,value=key\.strip\(\),value\.strip\(\)
ifkeyin\(’DOC\_TOP\_K’,’SENT\_TOP\_K’\):
config\[key\.lower\(\)\]=int\(value\)
elifkey==’HYBRID\_MODE’:
config\[key\.lower\(\)\]=value\.lower\(\)==’true’
else:
config\[key\.lower\(\)\]=value
else:
config=\{
’db\_path’:’\.\.\.chroma\_db’,’model\_path’:’\.\.\.all\-MiniLM\-L6\-v2’,
’doc\_top\_k’:3,’sent\_top\_k’:5,’hybrid\_mode’:True
\}
returnconfig
def\_init\_chromadb\(self\):
"""InitializeChromaDBconnectionandcollections"""
try:
importchromadb
fromchromadb\.utilsimportembedding\_functions
self\.client=chromadb\.PersistentClient\(path=self\.config\[’db\_path’\]\)
model=self\.config\[’model\_path’\]ifos\.path\.exists\(self\.config\[’model\_path’\]\)else"all\-MiniLM\-L6\-v2"
self\.embedding\_function=embedding\_functions\.SentenceTransformerEmbeddingFunction\(model\_name=model\)
self\.doc\_collection=self\.client\.get\_collection\("documents"\)
self\.sent\_collection=self\.client\.get\_collection\("sentences"\)
exceptExceptionase:
self\.doc\_collection=self\.sent\_collection=None
asyncdef\_\_call\_\_\(self,instruction:str="",context:str="",top\_k:int=None\)\-\>str:
"""Executevectorsearchandreturnformattedretrieveddocuments\."""
ifnotself\.doc\_collectionornotself\.sent\_collection:
return"Error:Vectordatabasenotinitialized\."
doc\_k=top\_korself\.config\[’doc\_top\_k’\]
query=awaitself\.\_process\_query\(instruction,context\)
retrieved\_data=self\.\_hybrid\_retrieval\(query,doc\_k,self\.config\[’sent\_top\_k’\]\)
returnself\.\_format\_context\(retrieved\_data\)
asyncdef\_process\_query\(self,instruction:str,context:str\)\-\>str:
"""Processandcombinequeryfrominstructionandcontext\."""
ifinstructionandcontext:
returnf"\{instruction\}\{context\}"
returninstructionor\(context\[:200\]ifcontextelseself\.problem\_text\[:200\]or"generalinformation"\)
def\_hybrid\_retrieval\(self,query:str,doc\_k:int,sent\_k:int\)\-\>Dict:
"""Performhybriddocumentandsentencelevelretrieval\."""
retrieved\_data=\{’documents’:\[\],’scores’:\[\]\}
try:
ifself\.config\.get\(’hybrid\_mode’,True\):
doc\_results=self\.doc\_collection\.query\(query\_texts=\[query\],n\_results=doc\_k\)
fori,\(doc\_id,doc\_text,meta,dist\)inenumerate\(zip\(
doc\_results\[’ids’\]\[0\],doc\_results\[’documents’\]\[0\],
doc\_results\[’metadatas’\]\[0\],doc\_results\[’distances’\]\[0\]\)\):
retrieved\_data\[’documents’\]\.append\(\{
’doc\_id’:doc\_id,’title’:meta\.get\(’title’,’Unknown’\),
’text’:doc\_text\[:500\],’type’:’document’,’rank’:i\+1\}\)
retrieved\_data\[’scores’\]\.append\(float\(dist\)\)
sent\_results=self\.sent\_collection\.query\(query\_texts=\[query\],n\_results=sent\_k\)
fori,\(sid,stxt,meta,dist\)inenumerate\(zip\(
sent\_results\[’ids’\]\[0\],sent\_results\[’documents’\]\[0\],
sent\_results\[’metadatas’\]\[0\],sent\_results\[’distances’\]\[0\]\)\):
ifi<3:
retrieved\_data\[’documents’\]\.append\(\{
’doc\_id’:sid,’title’:meta\.get\(’title’,’Unknown’\),
’text’:stxt,’type’:’sentence’,’rank’:i\+1\}\)
retrieved\_data\[’scores’\]\.append\(float\(dist\)\)
exceptException:
pass
returnretrieved\_data
def\_format\_context\(self,retrieved\_data:Dict\)\-\>str:
"""Formatretrieveddocumentsintoreadablecontextstring\."""
ifnotretrieved\_data\[’documents’\]:
return"Norelevantdocumentsfound\."
parts=\["\*\*RetrievedInformation:\*\*\\n"\]
fordinretrieved\_data\[’documents’\]:
parts\.append\(f"\[\{d\[’type’\]\.title\(\)\}:\{d\[’title’\]\}\]\{d\[’text’\]\}\\n"\)
return"\\n"\.join\(parts\)
Listing 3:Implementation of theVectorSearchoperator for retrieval\-augmented generation\.
### B\.2Input and Output of the Model
Themodel inputconsists of two parts: \(1\)Task Type Description, which elucidates the domain characteristics of the target problem family and the input\-output formats of each belonging problem instance\. The block below shows the completeTask Type Descriptionfor GSM8K\.
Thisdomaintestsmulti\-stepmathematicalreasoningusingbasicarithmeticoperations\.
\-\*\*AnswerFormat\*\*:Singlenumericalvalue\(integerordecimal\)
\-\*\*SolutionSteps\*\*:2\-8stepreasoningchainsusing\+,\-,\*,/
\-\*\*Critical\*\*:Trackintermediateresultsandunitsthroughout
\-\*\*Validation\*\*:Finalanswermustbenumericallyexact
\-\*\*NoComplexMath\*\*:Onlyelementaryarithmetic,noalgebraorcalculus
\-\*\*SequentialOperations\*\*:Step\-by\-stepcalculationsbuildingonpreviousresults
\-\*\*RateProblems\*\*:Distance/speed/time,workrates,unitprices
\-\*\*Distribution\*\*:Dividingquantities,equalsharing,remainders
\-\*\*Proportions\*\*:Percentages,fractions,ratios,scaling
\-\*\*Multi\-entity\*\*:Trackdifferentquantitiesformultiplepeople/objects
1\.Extractallnumericalvaluesandtheircontext
2\.Identifywhatthequestionasksfor
3\.Buildstep\-by\-stepcalculationchain
4\.Showintermediateresultsexplicitly
5\.Returnfinalnumericalansweronly
‘‘‘
\-\-\-
\*\*QUESTION:\*\*
\[Completewordproblemtext\]
\-\-\-
‘‘‘
Multipleproblemsfollowthesamestructureifprovided\.
Listing 4:CompleteTask Type Descriptionof GSM8K including domain overview, key requirements and the format of problem instance\.\(2\)Operator Descriptions, which define the functions, parameters, and input\-output formats of each available operator \(whether pre\-set or user\-defined\)\. The block below shows the completeOperator Descriptionsof the operator set𝖮𝗉𝗌=\\displaystyle\\mathsf\{Ops\}=\(Generate,Summarize,Revise,Ensemble\)\.
Alloperatorsfollowaconsistentinterfacepatternandareinitializedwiththeproblemtext\.
\*\*Generate:CREATEnewinformation\*\*
\-\*\*Signature:\*\*‘awaitself\.generate\(instruction:str,context:str=""\)\-\>str‘
\-\*\*Purpose:\*\*Producesnewtext,analysis,orreasoningbasedonstrategicinstructions
\*\*Revise:IMPROVEexistinginformation\*\*
\-\*\*Signature:\*\*‘awaitself\.revise\(instruction:str,context:str\)\-\>str‘
\-\*\*Purpose:\*\*Critiquesandrefinesexistingtextbasedonspecificimprovementcriteria
\*\*Summarize:COMPRESSinformation\*\*
\-\*\*Signature:\*\*‘awaitself\.summarize\(instruction:str,context:str\)\-\>str‘
\-\*\*Purpose:\*\*Condensestextwhilepreservingkeyinformationrelevanttotheproblem
\*\*Ensemble:DECIDEbetweenorsynthesizeoptions\*\*
\-\*\*Signature:\*\*‘awaitself\.ensemble\(instruction:str,contexts:List\[str\]\)\-\>str‘
\-\*\*Purpose:\*\*Evaluates,compares,ormergesmultiplecandidatesolutions
Listing 5:CompleteOperator Descriptionsof an operator set\.Theoutputrequires a structuredWorkflowaimed at efficiently solving all problem instances under the task type using the given operator set based on the template below\.
‘‘‘python
classWorkflow:
def\_\_init\_\_\(self,config,problem\)\-\>None:
self\.config=config
self\.problem\_text=problem
self\.llm=create\(config\)
self\.generate=operator\.Generate\(self\.llm,self\.problem\_text\)
self\.revise=operator\.Revise\(self\.llm,self\.problem\_text\)
self\.summarize=operator\.Summarize\(self\.llm,self\.problem\_text\)
self\.ensemble=operator\.Ensemble\(self\.llm,self\.problem\_text\)
asyncdefrun\_workflow\(self\):
"""
Implementthecoreproblem\-solvinglogichere\.
"""
importasyncio
‘‘‘
Listing 6:outputtemplate of given𝖮𝗉𝗌=\\displaystyle\\mathsf\{Ops\}=\(Generate,Summarize,Revise,Ensemble\)\.
## Appendix CDetails of Supervised Fine\-Tuning
The supervised fine\-tuning \(SFT\) stage initializes the planner modelπθ\\displaystyle\\pi\_\{\\theta\}to generate syntactically correct workflows following the required template structure \(see Appendix[B\.2](https://arxiv.org/html/2606.30704#A2.SS2)for the detailed input\-output format\)\. This stage addresses the cold start problem by teaching the model the basic grammar of workflow construction before reinforcement learning optimization\.
Dataset Construction Pipeline\.We construct approximately 1,300 high\-quality \(\[𝖢,𝖮𝗉𝗌\],𝖶\\displaystyle\[\\mathsf\{C\},\\mathsf\{Ops\}\],\\mathsf\{W\}\) pairs usingQwen\-Maxas the expert model\. The construction follows a four\-stage pipeline:
1. 1\.Prompt Crafting: Construct input prompts combining task descriptions𝖢\\displaystyle\\mathsf\{C\}\(domain characteristics, input\-output formats\) and operator specifications𝖮𝗉𝗌\\displaystyle\\mathsf\{Ops\}\(function signatures, purposes\) following the format defined in Appendix[B\.2](https://arxiv.org/html/2606.30704#A2.SS2)\.
2. 2\.Expert Generation: Feed prompts toQwen\-MaxAPI to obtain comprehensive responses including workflow explanations and complete executable code\.
3. 3\.Code Extraction: Parse API responses to extract clean workflow code𝖶\\displaystyle\\mathsf\{W\}, discarding natural language explanations\.
4. 4\.Quality Verification: Execute each extracted workflow on 1\-2 randomly sampled problem instances𝗉∼𝖢\\displaystyle\\mathsf\{p\}\\sim\\mathsf\{C\}to ensure \(a\) no syntax errors and \(b\) correct solutions\. Only validated workflows are retained\.
This pipeline is applied across four tasks \(GSM8K, DROP, MBPP, Humaneval\) with the basic operator set𝖮𝗉𝗌SFT=\(Generate,Summarize,Revise,Ensemble\)\\displaystyle\\mathsf\{Ops\}^\{\\text\{SFT\}\}=\(\\texttt\{Generate\},\\texttt\{Summarize\},\\texttt\{Revise\},\\texttt\{Ensemble\}\), producing diverse workflow patterns that establish the foundation for RLVR optimization\. To ensure stable training on this limited dataset, we employ parameter\-efficient fine\-tuning with LoRA configuration, as detailed in Section[C\.2](https://arxiv.org/html/2606.30704#A3.SS2)\.
### C\.1Dataset Construction Examples
To illustrate the construction pipeline, we present a concrete example for the GSM8K mathematical reasoning task\. The input prompt \(Listing[7](https://arxiv.org/html/2606.30704#LST7)\) combines task description and operator specifications:
Thisdomaintestsmulti\-stepmathematicalreasoningusingbasicarithmeticoperations\.
\-\*\*AnswerFormat\*\*:Singlenumericalvalue\(integerordecimal\)
\-\*\*SolutionSteps\*\*:2\-8stepreasoningchainsusing\+,\-,\*,/
\-\*\*Critical\*\*:Trackintermediateresultsandunitsthroughout
\-\*\*Validation\*\*:Finalanswermustbenumericallyexact
\-\*\*NoComplexMath\*\*:Onlyelementaryarithmetic,noalgebraorcalculus
\-\*\*SequentialOperations\*\*:Step\-by\-stepcalculationsbuildingonpreviousresults
\-\*\*RateProblems\*\*:Distance/speed/time,workrates,unitprices
\-\*\*Distribution\*\*:Dividingquantities,equalsharing,remainders
\-\*\*Proportions\*\*:Percentages,fractions,ratios,scaling
\-\*\*Multi\-entity\*\*:Trackdifferentquantitiesformultiplepeople/objects
1\.Extractallnumericalvaluesandtheircontext
2\.Identifywhatthequestionasksfor
3\.Buildstep\-by\-stepcalculationchain
4\.Showintermediateresultsexplicitly
5\.Returnfinalnumericalansweronly
Alloperatorsfollowaconsistentinterfacepatternandareinitializedwiththeproblemtext\.
\*\*Generate:CREATEnewinformation\*\*
\-\*\*Signature:\*\*‘awaitself\.generate\(instruction:str,context:str=""\)\-\>str‘
\-\*\*Purpose:\*\*Producesnewtext,analysis,orreasoningbasedonstrategicinstructions
\*\*Revise:IMPROVEexistinginformation\*\*
\-\*\*Signature:\*\*‘awaitself\.revise\(instruction:str,context:str\)\-\>str‘
\-\*\*Purpose:\*\*Critiquesandrefinesexistingtextbasedonspecificimprovementcriteria
\*\*Summarize:COMPRESSinformation\*\*
\-\*\*Signature:\*\*‘awaitself\.summarize\(instruction:str,context:str\)\-\>str‘
\-\*\*Purpose:\*\*Condensestextwhilepreservingkeyinformationrelevanttotheproblem
\*\*Ensemble:DECIDEbetweenorsynthesizeoptions\*\*
\-\*\*Signature:\*\*‘awaitself\.ensemble\(instruction:str,contexts:List\[str\]\)\-\>str‘
\-\*\*Purpose:\*\*Evaluates,compares,ormergesmultiplecandidatesolutions
‘‘‘
\-\-\-
\*\*QUESTION:\*\*
\[Completewordproblemtext\]
\-\-\-
‘‘‘
Multipleproblemsfollowthesamestructureifprovided\.
YourtaskistowritethePythoncodeforthe‘run\_workflow‘methodwithintheprovidedtemplate\.
Focusoncreatingarobust,reusableworkflowthatleveragesdetailedinstructions\.
\*\*BaseTemplate:\*\*
‘‘‘python
classWorkflow:
def\_\_init\_\_\(self,config,problem\)\-\>None:
self\.config=config
self\.problem\_text=problem
self\.llm=create\(config\)
self\.generate=operator\.Generate\(self\.llm,self\.problem\_text\)
self\.revise=operator\.Revise\(self\.llm,self\.problem\_text\)
self\.summarize=operator\.Summarize\(self\.llm,self\.problem\_text\)
self\.ensemble=operator\.Ensemble\(self\.llm,self\.problem\_text\)
asyncdefrun\_workflow\(self\):
"""
Implementthecoreproblem\-solvinglogichere\.
"""
importasyncio
‘‘‘
Listing 7:Input prompt forQwen\-Maxto generate workflow examples \(GSM8K task\)\.Given this input prompt,Qwen\-Maxgenerates a comprehensive response that includes both natural language explanation of the workflow design and the complete workflow code\. Listing[8](https://arxiv.org/html/2606.30704#LST8)shows the raw output from the API:
Nowletmeunderstandthetaskbetterandimplementthe‘run\_workflow‘method\.
Thisisaworkflowforsolvingmulti\-stepmathematicalreasoningproblemsusingtheprovidedoperators\.
I’vecreatedarobustworkflowformulti\-stepmathematicalreasoningproblems\.Here’showitworks:
‘‘‘python
classWorkflow:
def\_\_init\_\_\(self,config,problem\)\-\>None:
self\.config=config
self\.problem\_text=problem
self\.llm=create\(config\)
self\.generate=operator\.Generate\(self\.llm,self\.problem\_text\)
self\.revise=operator\.Revise\(self\.llm,self\.problem\_text\)
self\.summarize=operator\.Summarize\(self\.llm,self\.problem\_text\)
self\.ensemble=operator\.Ensemble\(self\.llm,self\.problem\_text\)
asyncdefrun\_workflow\(self\):
"""
Implementthecoreproblem\-solvinglogichere\.
"""
extracted\_info=awaitself\.generate\(
instruction="Extractallnumericalvaluesfromtheproblem,includingtheirunitsandcontextualmeaning\(e\.g\.,’5apples’,’speedof60km/h’\)\.Listthemclearly\.",
context=self\.problem\_text
\)
target\_query=awaitself\.generate\(
instruction="Basedontheproblem,statepreciselywhatnumericalvalueisbeingaskedfor,includingitsexpectedunitifany\.",
context=self\.problem\_text
\)
plan=awaitself\.generate\(
instruction="Createaclear,step\-by\-stepplan\(2to8steps\)tosolvetheproblemusingonly\+,\-,\*,/operations\.Referencetheextractednumbersandspecifywhateachstepcomputes\.",
context=f"Extractedinfo:\{extracted\_info\}\\nTarget:\{target\_query\}"
\)
calculation=awaitself\.generate\(
instruction="Performthearithmeticstep\-by\-stepaspertheplan\.Showeachintermediateresultwithitsunitormeaning\.Ensureonlyelementaryarithmeticisused\.",
context=plan
\)
final\_answer\_raw=awaitself\.generate\(
instruction="Fromthecalculationsteps,extractonlythefinalnumericalanswer\(asanintegerordecimal\)\.Donotincludeunits,explanations,ortext\-\-onlythenumber\.",
context=calculation
\)
final\_answer\_clean=awaitself\.revise\(
instruction="Ensuretheoutputisasinglenumericalvalue\(e\.g\.,42or15\.75\),withnoextracharacters,units,orformatting\.Ifit’sawholenumber,donotincludedecimalplacesunlessrequired\.",
context=final\_answer\_raw
\)
returnfinal\_answer\_clean\.strip\(\)
‘‘‘
\*\*WorkflowDesign:\*\*
1\.\*\*ProblemExtraction\*\*\-Uses‘generate‘toparsetheproblem,extractingallnumericalvalues,thegoal,andrelationshipsbetweenquantities
2\.\*\*ParallelSolutionGeneration\*\*\-Generatesthreeindependentsolutionsusingdifferentapproaches:
\-Standardstep\-by\-stepforwardcalculation
\-Alternativeverificationmethod
\-Workingbackwardsfromthegoal
3\.\*\*SolutionRevision\*\*\-Eachsolutionisrevisedtocatcharithmeticerrors,verifyingeachcalculationstep
4\.\*\*EnsembleDecision\*\*\-Comparesallthreeverifiedsolutionstodeterminethecorrectanswerthroughmajorityvoteorerroranalysis
5\.\*\*AnswerExtraction\*\*\-Uses‘summarize‘toextractjustthefinalnumericalvalue
\*\*KeyFeatures:\*\*
\-Uses‘asyncio\.gather‘forparallelexecution\(generatingandrevisingsolutionssimultaneously\)
\-Multipleindependentsolutionsreducethechanceofsystematicerrors
\-Revisionstepcatchesarithmeticmistakes
\-Ensembleaggregatesresultsforhigheraccuracy
\-Cleannumericaloutputextractionattheend
Listing 8:Raw output fromQwen\-MaxAPI containing workflow explanation and code\.Finally, we parse the API response to extract only the executable workflow code, discarding the natural language explanations\. This extracted code forms a single training example in our SFT dataset\. Listing[9](https://arxiv.org/html/2606.30704#LST9)shows the clean workflow code extracted from the above output:
classWorkflow:
def\_\_init\_\_\(self,config,problem\)\-\>None:
self\.config=config
self\.problem\_text=problem
self\.llm=create\(config\)
self\.generate=operator\.Generate\(self\.llm,self\.problem\_text\)
self\.revise=operator\.Revise\(self\.llm,self\.problem\_text\)
self\.summarize=operator\.Summarize\(self\.llm,self\.problem\_text\)
self\.ensemble=operator\.Ensemble\(self\.llm,self\.problem\_text\)
asyncdefrun\_workflow\(self\):
"""
Implementthecoreproblem\-solvinglogichere\.
"""
extracted\_info=awaitself\.generate\(
instruction="Extractallnumericalvaluesfromtheproblem,includingtheirunitsandcontextualmeaning\(e\.g\.,’5apples’,’speedof60km/h’\)\.Listthemclearly\.",
context=self\.problem\_text
\)
target\_query=awaitself\.generate\(
instruction="Basedontheproblem,statepreciselywhatnumericalvalueisbeingaskedfor,includingitsexpectedunitifany\.",
context=self\.problem\_text
\)
plan=awaitself\.generate\(
instruction="Createaclear,step\-by\-stepplan\(2to8steps\)tosolvetheproblemusingonly\+,\-,\*,/operations\.Referencetheextractednumbersandspecifywhateachstepcomputes\.",
context=f"Extractedinfo:\{extracted\_info\}\\nTarget:\{target\_query\}"
\)
calculation=awaitself\.generate\(
instruction="Performthearithmeticstep\-by\-stepaspertheplan\.Showeachintermediateresultwithitsunitormeaning\.Ensureonlyelementaryarithmeticisused\.",
context=plan
\)
final\_answer\_raw=awaitself\.generate\(
instruction="Fromthecalculationsteps,extractonlythefinalnumericalanswer\(asanintegerordecimal\)\.Donotincludeunits,explanations,ortext\-\-onlythenumber\.",
context=calculation
\)
final\_answer\_clean=awaitself\.revise\(
instruction="Ensuretheoutputisasinglenumericalvalue\(e\.g\.,42or15\.75\),withnoextracharacters,units,orformatting\.Ifit’sawholenumber,donotincludedecimalplacesunlessrequired\.",
context=final\_answer\_raw
\)
returnfinal\_answer\_clean\.strip\(\)
Listing 9:Extracted workflow code for SFT training data\.The above example demonstrates the complete four\-stage pipeline from input prompt to validated workflow code, illustrating how each training pair is constructed and verified\.
### C\.2LoRA Configuration
To mitigate the risk of mode collapse when fine\-tuning on this limited dataset of approximately 1,300 examples, we employ Low\-Rank Adaptation \(LoRA\) with rank\-16\\displaystyle 16\(Huet al\.,[2022](https://arxiv.org/html/2606.30704#bib.bib48)\)and train for one epoch with batch size of16\\displaystyle 16, as illustrated in Figure[3](https://arxiv.org/html/2606.30704#S5.F3)\. This parameter\-efficient approach serves as an effective regularization mechanism: preliminary experiments with full\-parameter fine\-tuning resulted in degenerate repetition patterns \(Listing[10](https://arxiv.org/html/2606.30704#LST10)\), where the model generates circular, non\-terminating reasoning loops instead of producing valid workflows\.
Tosolvethisproblem,weneedtofirstunderstandwhattheproblemisasking\.Theproblemisaskingustofindtheanswer\.Tofindtheanswer,weneedtosolvethisproblem\.Tosolvethisproblem,weneedtofirstunderstandwhattheproblemisasking\.Theproblemisaskingustofindtheanswer\.Tofindtheanswer,weneedtosolvethisproblem\.Tosolvethisproblem,weneedtofirstunderstandwhattheproblemisasking\.Theproblemisaskingustofindtheanswer\.Tofindtheanswer,weneedtosolvethisproblem\.\.\.
Listing 10:Example of degenerate repetition pattern \(mode collapse\) observed during full\-parameter fine\-tuning on the limited SFT dataset\.
## Appendix DDetails of Reinforcement Learning with Verifiable Rewards
The task set remains the same as the SFT stage:
𝒟trainRLVR=𝒟trainSFT=\{GSM8K, DROP, MBPP, Humaneval\}\\mathcal\{D\}\_\{\\text\{train\}\}^\{\\text\{RLVR\}\}=\\mathcal\{D\}\_\{\\text\{train\}\}^\{\\text\{SFT\}\}=\\\{\\text\{GSM8K, DROP, MBPP, Humaneval\}\\\}To enhance the model’s generalization to diverse operator configurations, we train with four different operator sets that progressively introduce novel operators beyond the base SFT set:
𝖮𝗉𝗌RLVR,1\\displaystyle\\displaystyle\\mathsf\{Ops\}^\{\\text\{RLVR\},1\}=\(Generate,Summarize,Revise,Ensemble\)\\displaystyle\\displaystyle=\(\\texttt\{Generate\},\\texttt\{Summarize\},\\texttt\{Revise\},\\texttt\{Ensemble\}\)𝖮𝗉𝗌RLVR,2\\displaystyle\\displaystyle\\mathsf\{Ops\}^\{\\text\{RLVR\},2\}=\(Generate,Summarize,Revise,Ensemble,Programmer\)\\displaystyle\\displaystyle=\(\\texttt\{Generate\},\\texttt\{Summarize\},\\texttt\{Revise\},\\texttt\{Ensemble\},\\texttt\{Programmer\}\)𝖮𝗉𝗌RLVR,3\\displaystyle\\displaystyle\\mathsf\{Ops\}^\{\\text\{RLVR\},3\}=\(Generate,Summarize,Revise,Ensemble,Decompose\)\\displaystyle\\displaystyle=\(\\texttt\{Generate\},\\texttt\{Summarize\},\\texttt\{Revise\},\\texttt\{Ensemble\},\\texttt\{Decompose\}\)𝖮𝗉𝗌RLVR,4\\displaystyle\\displaystyle\\mathsf\{Ops\}^\{\\text\{RLVR\},4\}=\(Generate,Summarize,Revise,Ensemble,Programmer,Decompose\)\\displaystyle\\displaystyle=\(\\texttt\{Generate\},\\texttt\{Summarize\},\\texttt\{Revise\},\\texttt\{Ensemble\},\\texttt\{Programmer\},\\texttt\{Decompose\}\)
During each training iteration, we randomly sample one operator set from\{𝖮𝗉𝗌RLVR,i\}i=14\\displaystyle\\\{\\mathsf\{Ops\}^\{\\text\{RLVR\},i\}\\\}\_\{i=1\}^\{4\}along with a task from𝒟trainRLVR\\displaystyle\\mathcal\{D\}\_\{\\text\{train\}\}^\{\\text\{RLVR\}\}, forming diverse domain combinations\(𝖢,𝖮𝗉𝗌\)\\displaystyle\(\\mathsf\{C\},\\mathsf\{Ops\}\)for meta\-learning\. This diversity ensures the planner learns operator\-agnostic workflow construction principles rather than memorizing fixed operator\-task associations\.
## Appendix ECase Study: Workflow Design Transformation After Training
### E\.1Overview
To better understand the effectiveness of our training paradigm, we conduct a critical ablation study analyzing changes in model behavior before and after training\. We compare two randomly selected workflows generated by the untrained base model \(Qwen3\-8B\) versus the fully trainedMetaFlowmodel after our two\-stage training\.
### E\.2Impact of Training on Workflow Generation Behavior
Before Training \(Base Model Qwen3\-8B\):Without SFT and RLVR optimization, the base model generates workflows with multi\-step logic following a linear process: extract function name→\\displaystyle\\rightarrowsummarize→\\displaystyle\\rightarrowgenerate→\\displaystyle\\rightarrowrevise→\\displaystyle\\rightarrowensemble\.
classWorkflow:
asyncdefrun\_workflow\(self\):
func\_name=awaitself\.generate\(
instruction="Extractthefunctionnamefromthetestcases\.
ReturnONLYthefunctionname,nothingelse\.",
context=self\.problem\_text
\)
problem\_summary=awaitself\.summarize\(
instruction="Summarizetheproblemdescriptionandtestcases
tocreateaclearproblemstatement\.",
context=self\.problem\_text
\)
generated\_code=awaitself\.generate\(
instruction=f"WriteaPythonfunctionnamed’\{func\_name\}’\.\.\.
ReturnONLYthefunctiondefinition,nothingelse\.",
context=problem\_summary
\)
revised\_code=awaitself\.revise\(\.\.\.\)
final\_code=awaitself\.ensemble\(contexts=\[generated\_code,revised\_code\]\)
returnfinal\_code
Listing 11:Workflow generated by the untrained base model\.Analysis:While structured, this workflow has potential weaknesses:
1. 1\.Information Bottleneck:Thesummarizestep, intended to condense information, risks losing critical details or constraints from the original problem description\.
2. 2\.Instruction Ambiguity:Vague instructions like ”Return ONLY the function definition” can be misinterpreted, leading to incomplete code that lacks necessary import statements or helper functions\.
After Training \(MetaFlow Model\):In contrast, theMetaFlowmodel optimized through our two\-stage training paradigm generates a workflow that, while maintaining complexity, is significantly more robust and methodical in its approach, and has learned the self\-consistency operator unseen during training\.
%\-\-\-DONOTIMPORTHERE\-\-\-
classWorkflow:
def\_\_init\_\_\(self,config,problem\)\-\>None:
self\.config=config
self\.problem\_text=problem
self\.llm=create\(config\)
self\.generate=operator\.Generate\(self\.llm,self\.problem\_text\)
self\.revise=operator\.Revise\(self\.llm,self\.problem\_text\)
self\.summarize=operator\.Summarize\(self\.llm,self\.problem\_text\)
self\.ensemble=operator\.Ensemble\(self\.llm,self\.problem\_text\)
self\.selfconsistency=operator\.SelfConsistency\(self\.llm,self\.problem\_text\)
asyncdefrun\_workflow\(self\):
"""
Implementthecoreproblem\-solvinglogichere\.
Remember:
\-Usedetailed,comprehensiveinstructions
\-Dynamicinstructionconstructionispowerful
\-Alloperatorsexpect\(instruction:str,context:str\)exceptEnsemblewhichtakescontexts:List\[str\]
"""
importasyncio
function\_name=awaitself\.generate\(
instruction="""
Analyzethetestcasesprovidedandextractthefunctionname\.
Thefunctionnameshouldmatchthenamingconventionusedinthetestcases\.
ReturnONLYthefunctionname,nothingelse\.
""",
context=self\.problem\_text
\)
input\_types\_output=awaitself\.generate\(
instruction="""
Analyzethetestcasesprovidedandextracttheinputtypesandexpectedoutputs\.
Formattheresponseasadictionarywherekeysaretheparameternamesandvaluesarethetypes\.
Also,identifytheexpectedoutputformat\.
ReturnONLYthestructuredinformation,nothingelse\.
""",
context=self\.problem\_text
\)
implementations=awaitasyncio\.gather\(
self\.generate\(
instruction=f"""
Giventheproblemdescription:\{self\.problem\_text\}
GenerateaPythonfunctionthatsatisfiesthetestcases\.
Ensurethatthefunctionnameis’\{function\_name\}’\.
Includeallnecessaryimportsatthebeginningofthefunction\.
Usetheextractedinputtypesandexpectedoutputs:\{input\_types\_output\}\.
""",
context=self\.problem\_text
\),
self\.generate\(
instruction=f"""
Giventheproblemdescription:\{self\.problem\_text\}
GenerateanotherPythonfunctionthatsatisfiesthetestcases\.
Ensurethatthefunctionnameis’\{function\_name\}’\.
Includeallnecessaryimportsatthebeginningofthefunction\.
Usetheextractedinputtypesandexpectedoutputs:\{input\_types\_output\}\.
""",
context=self\.problem\_text
\)
\)
best\_implementation=awaitself\.selfconsistency\(
instruction=f"""
Evaluatethefollowingcandidateimplementations:
\{implementations\[0\]\}
\{implementations\[1\]\}
Selectthebestimplementationbasedonthefollowingcriteria:
\-Consistencywiththetestcases
\-Logicalcorrectness
\-Efficientandcleancode
\-Properuseofimportsandfunctionsignature
ReturnONLYthebestimplementation,nothingelse\.
""",
context=self\.problem\_text
\)
returnbest\_implementation
Listing 12:Workflow generated by the trainedMetaFlowmodel\.Analysis:The trained model’s workflow exhibits several key improvements contributing to its robustness:
1. 1\.From Compression to Structured Extraction:The model avoids the potentially lossysummarizestep\. Instead, it performs targeted extractions to parse unstructured text into structured data \(e\.g\., function name, I/O types\)\. This approach preserves information integrity and provides a more reliable foundation for subsequent steps\.
2. 2\.Parallel Exploration for Increased Robustness:Rather than following a single generation\-and\-revision path, the model generates multiple, independent candidate solutions in parallel usingasyncio\.gather\. This multi\-path exploration inherently increases the robustness of the process by diversifying the solution space and reducing the risk of settling on a single, flawed implementation\.
3. 3\.More Explicit and Context\-Aware Instructions:The instructions are dynamically constructed using f\-strings to include context from prior steps \(e\.g\., ‘function\_name‘, ‘input\_types\_output‘\)\. This makes the prompts highly specific and unambiguous, directly mitigating the weaknesses of the base model and ensuring that each generative step is precisely guided\.
## Appendix FSelf Consistency Operator: Low\-Cost Integration Example
This section demonstratesMetaFlow’s ability to immediately generate effective workflows with newly integrated operators without retraining\. After introducing theSelfConsistencyoperator \(which encapsulates parallel generation with majority voting\), the model generates the following workflow for GSM8K mathematical reasoning through a single inference\.
classWorkflow:
def\_\_init\_\_\(self,config,problem\)\-\>None:
self\.config=config
self\.problem\_text=problem
self\.llm=create\(config\)
self\.generate=operator\.Generate\(self\.llm,self\.problem\_text\)
self\.revise=operator\.Revise\(self\.llm,self\.problem\_text\)
self\.summarize=operator\.Summarize\(self\.llm,self\.problem\_text\)
self\.ensemble=operator\.Ensemble\(self\.llm,self\.problem\_text\)
self\.self\_consistency=operator\.SelfConsistency\(
self\.llm,
self\.problem\_text,
n\_samples=5,
similarity\_threshold=0\.9,
return\_full\_info=False
\)
asyncdefrun\_workflow\(self\):
"""
Implementthecoreproblem\-solvinglogichere\.
Remember:
\-Usedetailed,comprehensiveinstructions
\-Dynamicinstructionconstructionispowerful
\-Alloperatorsexpect\(instruction:str,context:str\)exceptEnsemblewhichtakescontexts:List\[str\]
"""
importasyncio
sc\_instruction=\(
"Solvethismathproblemstepbystep\."
"Showallcalculationsclearly\."
"Attheend,stateyourfinalnumericalanswer\."
\)
sc\_answer=awaitself\.self\_consistency\(
instruction=sc\_instruction,
context="",
answer\_type="numeric"
\)
format\_instruction=\(
f"Thecalculatedansweris:\{sc\_answer\}\\n\\n"
"ExtractONLYthefinalnumericalanswer\."
"Ifit’sadecimal,roundtoareasonableprecision\."
"Iftheanswerrepresentsacountofitems/people,itshouldbeawholenumber\."
"ReturnONLYthenumber,nothingelse\."
\)
final\_answer=awaitself\.generate\(
instruction=format\_instruction,
context=sc\_answer
\)
returnfinal\_answer\.strip\(\)
Listing 13:Example workflow generated byMetaFlowfor GSM8K after integrating theSelfConsistencyoperator\. The workflow demonstrates immediate operator utilization: \(1\) invokingSelfConsistencywith n=5 parallel samples and similarity\-based voting, and \(2\) formatting the numeric answer\. This workflow was generated without any model retraining, showcasing low\-cost operator extensibility\.
## Appendix GCase Study: Zero\-Shot Workflow Generation with Novel VectorSearch Operator
This case study demonstratesMetaFlow’s zero\-shot generalization to the novelVectorSearchoperator on HotpotQA multi\-hop question answering\. The operator was never encountered during SFT or RLVR training, yet the model successfully generates workflows that orchestrate complex retrieval\-reasoning pipelines\. Listing[14](https://arxiv.org/html/2606.30704#LST14)shows the highest\-scoring workflow \(0\.74 accuracy\) among 100 generated candidates, which achieves 60\.9% improvement over the CoT\+RAG baseline \(0\.46 accuracy\)\.
classWorkflow:
def\_\_init\_\_\(self,config,problem\)\-\>None:
self\.config=config
self\.problem\_text=problem
self\.llm=create\(config\)
self\.generate=operator\.Generate\(self\.llm,self\.problem\_text\)
self\.revise=operator\.Revise\(self\.llm,self\.problem\_text\)
self\.summarize=operator\.Summarize\(self\.llm,self\.problem\_text\)
self\.ensemble=operator\.Ensemble\(self\.llm,self\.problem\_text\)
self\.vector\_search=operator\.VectorSearch\(self\.llm,self\.problem\_text\)
asyncdefrun\_workflow\(self\):
"""
Implementthecoreproblem\-solvinglogichere\.
Remember:
\-Usedetailed,comprehensiveinstructions
\-Dynamicinstructionconstructionispowerful
\-Alloperatorsexpect\(instruction:str,context:str\)exceptEnsemblewhichtakescontexts:List\[str\]
"""
importasyncio
extraction\_instruction=\(
"Identifyallnamedentities,keyterms,andconceptsinthequestion\."
"Focusonentitiesthatarelikelytoappearinthedocumentsandarecriticalforansweringthequestion\."
\)
question\_entities=awaitself\.generate\(instruction=extraction\_instruction,context=self\.problem\_text\)
first\_search\_instruction=\(
f"Usetheextractedentities:\{question\_entities\}\."
"Performavectorsearchtofinddocumentsthatmentiontheseentities\."
"Prioritizedocumentsthatprovidefoundationalinformationaboutthequestion\."
\)
first\_retrieved\_docs=awaitself\.vector\_search\(instruction=first\_search\_instruction,context=self\.problem\_text,top\_k=5\)
analysis\_instruction=\(
f"Basedontheretrieveddocuments:\{first\_retrieved\_docs\}\."
"Identifyanysharedentities,relationships,orconnectionsbetweenthedocuments\."
"Highlighthowtheseconnectionscanhelpanswerthequestion\."
\)
connections\_analysis=awaitself\.generate\(instruction=analysis\_instruction,context=self\.problem\_text\)
second\_search\_instruction=\(
f"Usetheconnectionsidentified:\{connections\_analysis\}\."
"Performavectorsearchtofinddocumentsthatexplicitlyconnecttheentitiesorprovideadditionalcontext\."
\)
second\_retrieved\_docs=awaitself\.vector\_search\(instruction=second\_search\_instruction,context=self\.problem\_text,top\_k=5\)
synthesis\_instruction=\(
f"Combinetheinformationfromthefirstset:\{first\_retrieved\_docs\},"
f"andthesecondset:\{second\_retrieved\_docs\}\."
"Extracttheexactanswertothequestionbasedonthesynthesizedinformation\."
"Ensuretheanswerisconciseandfactuallyaccurate\."
\)
final\_answer=awaitself\.generate\(instruction=synthesis\_instruction,context=self\.problem\_text\)
returnfinal\_answer
Listing 14:Highest\-scoring workflow for HotpotQA using the novelVectorSearchoperator\. The workflow performs iterative multi\-hop reasoning: \(1\) entity extraction, \(2\) first\-hop document retrieval, \(3\) connection analysis, \(4\) second\-hop retrieval, and \(5\) answer synthesis\. This demonstratesMetaFlow’s ability to compose complex operator sequences for unseen tools through learned meta\-strategies\.### Analysis and Performance
the successful integration and application of a new tool\. In Step 2, the model dynamically constructs a search query from its initial analysis and invokes thevectorsearchoperator, effectively performing active information retrieval\. When evaluated on the HotpotQA downstream task, this approach achieved a60% search accuracy\. This result is significant as it confirms that our operator framework enables models to learn and effectively utilize unseen tools\.
### Note on Comparability with Baselines
It is crucial to highlight a fundamental difference between our evaluation and that of many previous works on HotpotQA\. Our methodology requires the model toactively perform a searchto find relevant information\. In contrast, prior baselines are often provided with the ground\-truth supporting documents as part of their input, thereby bypassing the challenging information retrieval step entirely\. Because our system solves a more complete and realistic version of the task that includes an explicit search phase, a direct comparison of end\-to\-end accuracy with such baselines is not meaningful\.Similar Articles
LLMZero: Discovering Adaptive Training Strategies for RL Post-Training via LLM Agents
LLMZero uses LLM agents to search over training trajectories via tree search, discovering adaptive multi-parameter transitions for RL post-training that outperform fixed schedules and grid search across diverse tasks.
G-Zero: Self-Play for Open-Ended Generation from Zero Data
This paper introduces G-Zero, a verifier-free framework that enables autonomous large language model self-improvement through co-evolutionary training using intrinsic rewards and hint-based guidance. It aims to overcome the limitations of proxy LLM judges in open-ended tasks by deriving supervision from internal distributional dynamics.
Generative Floor Plan Design with LLMs via Reinforcement Learning with Verifiable Rewards
This paper introduces a text-based approach for generative floor plan design that fine-tunes a large language model with reinforcement learning and verifiable rewards to improve adherence to topological and numerical constraints, achieving significant improvements over existing methods.
FlowLM: Few-Step Language Modeling via Diffusion-to-Flow Adaptation
FlowLM introduces a flow matching language model derived from pre-trained diffusion models via efficient fine-tuning, enabling high-quality few-step text generation that rivals 2,000-step diffusion sampling with far fewer training epochs.
MindZero: Learning Online Mental Reasoning With Zero Annotations
MindZero introduces a self-supervised reinforcement learning framework that trains multimodal large language models for efficient and robust online mental reasoning without requiring mental state annotations, outperforming model-based methods in accuracy and efficiency.