A dapt F low: Adaptive Workflow Optimization via Meta-Learning (2025)

Abstract: Recent advances in large language models (LLMs) have sparked growing interest in agentic workflows—structured sequences of LLM invocations designed to solve complex tasks. However, existing approaches often rely on static templates or manually designed workflows, which limit adaptability to diverse tasks and hinder scalability. We propose AdaptFlow, a natural language-based meta-learning framework inspired by model-agnostic meta-learning (MAML). AdaptFlow uses a bi-level optimization process: the inner loop performs task-specific adaptation via LLM-generated feedback, while the outer loop consolidates these refinements into a shared, generalizable initialization. Evaluated across question answering, code generation, and mathematical reasoning benchmarks, AdaptFlow consistently outperforms both manually crafted and automatically searched baselines, achieving state-of-the-art results with strong generalization across tasks and models.

## introduction recent progress in large language models (llms) @xcite @xcite has led to remarkable performance across diverse tasks, including question answering @xcite @xcite , code synthesis @xcite @xcite , and multi-turn dialogue @xcite @xcite . beyond static prediction, llms are increasingly being used as decision-making agents capable of dynamic reasoning and adaptive behavior @xcite @xcite . this development has given rise to the notion of agentic workflows, which organize llms into structured sequences of actions involving task decomposition, planning, tool use, execution, and selfreflection @xcite . such workflows have demonstrated strong performance in settings that require multistep reasoning @xcite , long-horizon planning @xcite , and external tool integration @xcite . while effective in controlled settings, manually designing agentic workflows is time-consuming and lacks scalability across diverse tasks. to address this, recent work has explored automated workflow construction through prompt optimization @xcite , hyperparameter tuning @xcite , and structural search @xcite @xcite . however, many of these methods @xcite represent workflows using fixed graph structures, which inherently limit the flexibility of the agentic workflow search space. recent frameworks such as adas @xcite and aflow @xcite adopt code-based workflow representations to enable robust and flexible search. however, as noted by @xcite , these methods typically generate a single static workflow for the entire task set, limiting their ability to generalize across heterogeneous datasets with diverse problem types. in addition, adas performs coarse-grained workflow updates, resulting in redundant context accumulation and growing complexity that hinders con-vergence. aflow alleviates some of these issues using monte carlo tree search, but its reliance on discrete updates and early pruning can restrict the exploration of more expressive workflow candidates. these limitations underscore two challenges simultaneously: c1. how to adaptively construct effective workflows for datasets containing diverse problems? c2. how to ensure convergent optimization in code search spaces? to tackle these challenges, we propose adapt-flow-a meta-optimization framework that incorporates principles from model-agnostic meta-learning (maml) @xcite into agentic workflow optimization. maml learns an initialization that enables rapid adaptation to new tasks via a bi-level optimization: the inner loop performs task-specific updates, and the outer loop updates the initialization to generalize across tasks. inspired by this structure, adaptflow learns a shared workflow initialization that can quickly adapt to diverse subtasks through symbolic updates guided by llm-generated feedback. specifically, adaptflow follows a bi-level optimization scheme, where the inner loop iteratively refines the workflow based on subtask-level feedback, while the outer loop consolidates these refinements into a generalizable initialization. to further enhance adaptability, we perform an additional unsupervised adaptation step at test time on each target subtask, leveraging semantic descriptions derived from input prompts. this design enables both effective subtask-specific adaptation (addressing c1) and stable convergence in code spaces (addressing c2), offering a scalable solution for general-purpose workflow construction. our key contributions are summarized as follows: in the outer loop, we aggregate subtask-level improvements into a shared initialization, further enhanced by a reflection step that revisits failure cases to improve robustness and convergence. ## experiment setup datasets we evaluate our method on eight public datasets across three domains: question answering, code generation, and mathematical reasoning. for humaneval @xcite and mbpp @xcite , we use the full datasets. following aflow @xcite , we sample 1,319 examples from the gsm8k test split @xcite . for math (hendrycks et al., 2021), we follow @xcite and select level-5 problems from four categories: combinatorics and probability, number theory, prealgebra, and pre-calculus. we also include two advanced math benchmarks: aime (openai, 2023) and olympiadbench @xcite . for drop @xcite and hotpotqa @xcite , we follow prior work @xcite @xcite and randomly sample 1,000 instances each. all datasets are split into validation and test sets with a 1:4 ratio. see baselines we compare our method against two categories of baselines: manually designed workflows and automatically optimized workflows for llms. manual workflows include widely used prompting strategies and agent-based methods: vanilla prompting, chain-of-thought (cot) @xcite , reflexion @xcite , llm debate (du et al., 2023), step-back abstraction @xcite , quality-diversity (qd) @xcite , and dynamic role assignment @xcite . these approaches are constructed using fixed templates or heuristics without task-specific adaptation. automatically optimized workflows are derived through workflow optimization or search. we include adas @xcite and aflow @xcite , which learn or search for agentic workflow structures in a data-driven manner to improve llm performance across tasks. implementation details we use a decoupled architecture separating optimization and execution. gpt-4.1 (openai, 2024a) serves as the optimizer, while executors include deepseekv2.5 @xcite , gpt-4o-mini (openai, 2024b), claude-3.5-sonnet @xcite , and gpt-4o (openai, 2024c). all models are accessed via public apis with a fixed temperature of 0.5. the outer loop runs for 3 iterations, and the inner loop allows up to 6 updates per subtask. metrics we adopt task-specific evaluation metrics tailored to each dataset category. for mathematics benchmarks, including gsm8k, math, aime, and olympiadbench, we use the solve rate-the proportion of correctly solved problems-as the primary metric. for code generation tasks (humaneval and mbpp), we report pass@1, following the evaluation protocol of chen et al. @xcite , which measures the correctness of the top-1 generated solution. for question-answering datasets such as hotpotqa and drop, we adopt the f1 score to evaluate the overlap between predicted and ground-truth answers. ## conclusion we introduced adaptflow, a bi-level metaoptimization framework that learns adaptable agentic workflows via llm-guided symbolic feedback. across eight benchmarks, adaptflow outperforms both manual and automated baselines, with components like reflection and test-time adaptation enhancing robustness. overall, it offers a scalable, model-agnostic solution for automating workflow design.