The Research Report
Stop Hand-Crafting Your LLM Pipelines: FlowBot Discovers Them Automatically
Every LLM workflow you have ever built started the same way. You sketched out the steps on a whiteboard or in your head. You wrote prompts for each step. You tested, tweaked, and re-tweaked. Maybe you swapped the order of two calls. Maybe you added a verification step. Maybe you rewrote the retrieval prompt for the third time because it kept hallucinating entity names.
That process works. It produces real systems that solve real problems. But it scales poorly. Every new task requires a human designer. Every design choice encodes assumptions that might be wrong. And the space of possible workflows grows combinatorially as tasks get harder.
A new paper from Naver Search US and MIT asks a blunt question: what if the workflow discovered itself?
What FlowBot Is
FlowBot (workflow induction through bilevel optimization and textual gradients) is a method that automatically induces both the structure of an LLM workflow and the prompts for each step. You give it a dataset of input-output pairs. It gives you back a complete pipeline: how many steps, what each step does, what prompt each step uses, and whether any steps need tool access.
This is a different problem than prompt optimization. Tools like DSPy, TextGrad, and GEPA assume you already know the workflow structure. They tune prompts within a fixed pipeline. FlowBot starts from scratch. It decides the pipeline too.
The paper is "Inducing LLM Workflows with Bilevel Optimization and Textual Gradients" by Hongyeon Yu and Young-Bum Kim (Naver Search US) and Yoon Kim (MIT). arXiv:2604.26258. Version 2 appeared May 1, 2026.
The Core Idea: Bilevel Optimization
The key insight is treating workflow induction as two nested optimization problems.
The outer loop searches over workflow structure. Should this task have three steps or six? Should step 2 do retrieval or entity disambiguation? Should there be a verification step at the end? The outer loop proposes, modifies, adds, and deletes LLM calls. It works in text space. Each workflow step is described in natural language (e.g., "Wikipedia Search" or "Entity Disambiguation"). The outer loop edits these descriptions the same way the inner loop edits prompts: with textual gradients.
The inner loop fixes the structure and optimizes the prompts for each step. Given a workflow sketch with K steps, it runs a forward pass on training examples, computes a loss, then backpropagates textual gradients from the output back through each layer. Think of it like backpropagation in a neural network, except the "gradients" are natural language feedback and the "parameters" are prompts.
This analogy to deep learning is not cosmetic. The authors draw a direct parallel:
- The workflow sketch (which steps exist and in what order) is like the architecture of a neural network. It defines the computation graph.
- The prompts (detailed instructions for each step) are like the learnable parameters within each layer.
- The outer loop is neural architecture search. The inner loop is gradient-based training.
How Textual Gradients Work
A "textual gradient" is just an LLM reading the input, output, and loss for a step, then writing natural language feedback about what went wrong and how to fix it.
For the final layer in the workflow, the gradient LLM looks at the predicted output, the ground truth answer, and the loss. It generates feedback like "The answer 1865 is wrong. The correct answer is 1846. The verification step hallucinated the founding year. You should compare the extracted answer against retrieved evidence rather than generating from memory."
For intermediate layers, the gradient flows backward. The LLM sees what this step received as input, what it produced as output, and the gradient from the next layer downstream. It then produces feedback about how this step's output should change to help downstream steps succeed.
Each gradient gets aggregated across a batch. Then another LLM call updates the prompt, given the current prompt and the batch of gradients. The result is a revised prompt that should produce better behavior on the next forward pass.
This is the same general idea as TextGrad (Yuksekgonul et al., 2025) and DSPy's prompt optimization, but applied layer-by-layer within a multi-step workflow rather than to a single prompt in isolation.
How the Outer Loop Works
The outer loop takes a different kind of gradient. It looks at the entire workflow execution trace: the input, every intermediate output, the final prediction, the ground truth, and the loss. Then an LLM proposes structural changes. Add a step. Remove a step that is not helping. Merge two steps that are doing redundant work. Split one step into two more specific steps.
These proposals get aggregated across a batch too. Another LLM call produces the updated workflow sketch.
The inner and outer loops run alternately. For each training batch, FlowBot runs the outer loop once (to adjust structure) and the inner loop five times (to refine prompts). The whole process takes one epoch over the training data.
Initialization
FlowBot does not start from a hand-designed workflow. It starts from nothing. First, it feeds training examples to a bare LLM with no instructions. Then it runs one outer-loop gradient step on the resulting failures to produce an initial workflow sketch. Another LLM generates initial prompts for each step in the sketch. From there, bilevel optimization takes over.
What They Tested
The authors evaluated FlowBot on ten benchmarks across several task types:
- Multi-hop QA: HotpotQA (two variants: tool-augmented and context-only)
- Instruction following: IFBench
- Multi-hop verification: HoVer
- Privacy-conscious delegation: PUPA
- Reading comprehension: DROP
- Math reasoning: GSM8K, MATH
- Code generation: HumanEval, MBPP
That covers a wide range. Not just question answering. Code generation, math, and constrained instruction following too.
They used GPT-4.1 mini for all LLM calls across all methods, ensuring a fair comparison.
Training used one epoch, batch size 5, with two bilevel optimization loops per batch. Each loop runs one outer step and five inner steps. Model selection uses validation performance.
Results Against Prompt Optimization Baselines
The first comparison is against methods that optimize prompts within a fixed, human-designed workflow structure. The baselines here are GEPA (the current state of the art for prompt optimization within fixed workflows), along with Trace, MIPROv2, and TextGrad for context.
GEPA starts from a hand-crafted workflow designed by domain experts. It then evolves the prompts within that structure. FlowBot has to discover both the workflow and the prompts from scratch.
Results on the four GEPA benchmarks (HotpotQA1, IFBench, HoVer, PUPA):
- HotpotQA1: FlowBot matches or exceeds GEPA on the retrieval-heavy multi-hop QA task. This makes sense because FlowBot can discover useful structural decompositions that GEPA's fixed workflow might not include.
- HoVer: FlowBot beats GEPA on multi-hop verification. Again, the ability to add verification and cross-checking steps matters.
- IFBench and PUPA: FlowBot stays competitive on instruction following and privacy delegation tasks, where a single well-prompted call often works well and workflow structure matters less.
The key takeaway: FlowBot matches or beats methods that start from human-designed workflows, despite having to discover its own structure from data.
Results Against Automated Workflow Generation
The second comparison is against AFlow, which also generates workflow structure automatically. AFlow searches over workflow structures expressed as code (program space) rather than natural language (text space). AFlow uses an LLM to propose and modify code that defines the workflow. It does not use backpropagation-based modular updates.
The original AFlow paper used Claude 3.5 Sonnet as the optimizer and GPT-4o mini as the executor. For fair comparison, the FlowBot authors re-implemented AFlow with GPT-4.1 mini throughout.
Results on six AFlow benchmarks (HotpotQA2, DROP, HumanEval, MBPP, GSM8K, MATH):
- FlowBot outperforms AFlow on four of six benchmarks.
- AFlow wins on DROP and MATH.
- The differences are consistent, not outliers.
FlowBot also costs less. The authors report that running full iterations for both methods would cost $352.46 for AFlow (803K API calls) versus $165.39 for FlowBot (145K API calls). FlowBot reaches its best validation performance faster and with fewer calls.
What the Discovered Workflows Look Like
This is where it gets interesting. Do the automatically discovered workflows make sense?
For HotpotQA, FlowBot discovered a six-step pipeline:
- Wikipedia Search
- Entity Disambiguation
- Targeted Retrieval (with tool access)
- Answer Verification (LLM-based)
- Answer Extraction
- Final Synthesis
The human-designed workflow from GEPA for the same task follows a similar multi-hop retrieval pattern. The main difference: FlowBot explicitly decomposes entity disambiguation and query planning, while the human design handles these implicitly through summarization.
The discovered prompts are also sensible. Step 3 (Targeted Retrieval) gets tool access and uses it appropriately. Step 4 (Answer Verification) checks the extracted answer against retrieved evidence. These are not random. They reflect real decomposition of the reasoning required for multi-hop QA.
Does Backpropagation Actually Help?
The authors run ablation studies to check whether both the outer loop (structure search) and the inner loop (layer-wise backpropagation) matter.
Without the outer loop (fix the initial random sketch and only optimize prompts): performance drops. The initial structure matters, and optimizing it helps.
Without layer-wise backpropagation (optimize each prompt independently without propagating information about downstream errors): performance also drops. Knowing that step 5 hallucinated gives step 3 specific, actionable feedback about what to change. Without that signal, step 3 can only see its own input-output pair.
Both components are necessary. Removing either one hurts.
The authors also provide a detailed walkthrough of how textual backpropagation works in practice. On a HotpotQA question about Bucknell University's founding year, the workflow initially produced 1865 (wrong) instead of 1846 (correct). The forward pass traced the error to step 5, where the verification LLM hallucinated a wrong date despite receiving the correct information from upstream. The backward gradient flow then propagated this diagnosis to step 5 (fix the verification prompt) and further back to step 3 (improve retrieval targeting). After optimization, the workflow produced the correct answer.
Why This Matters for Agent Builders
You can stop whiteboarding pipeline topologies
The standard approach to building an LLM agent system is to sketch the pipeline manually, then prompt-engineer each node. FlowBot suggests an alternative: define the task with data, let the system discover the topology. This does not mean human design is never useful. But for well-defined tasks with available training data, automatic induction can match or exceed manual design.
The architecture-search analogy is productive
Treating workflow structure like neural architecture search reframes the problem in a useful way. Neural architecture search was controversial when it first appeared. People asked whether automated methods could beat skilled engineers designing networks by hand. The answer turned out to be: sometimes yes, especially when the search space is large and human intuition is unreliable. The same pattern may play out for LLM workflows.
Textual gradients are a general debugging tool
Even if you never run FlowBot end to end, the textual backpropagation idea is useful. When your multi-step pipeline produces a wrong answer, you can trace the error backward through each step. At each step, ask: given what this step received and what it produced, and given the downstream failure, what should this step have done differently? This is essentially what FlowBot automates. You can do it by hand. FlowBot makes it systematic.
Cost matters for practical adoption
FlowBot uses roughly 5x fewer API calls than AFlow to reach its best performance. At GPT-4.1 mini pricing, that is $165 versus $352 for a full run. These are not trivial differences if you are running workflow optimization as part of a production pipeline. Cheaper optimization makes it feasible to re-optimize when tasks shift, models update, or new data arrives.
Data efficiency is a feature, not a bug
FlowBot hits its performance ceiling fast, often within a few hundred training examples. The authors note this as a limitation. But for practical use, fast convergence is an advantage. You do not need a massive dataset to get a reasonable workflow. A few dozen labeled examples can produce a competitive pipeline.
Limitations and Open Questions
The paper is honest about what FlowBot cannot do yet:
Chains only, not DAGs. The current formulation assumes workflows are sequential chains (with possible loops back to earlier steps). It does not handle branching or parallel execution paths. Many real workflows need conditional branches, fan-out, or parallel tool calls.
Small-scale evaluation. The benchmarks are standard but limited. The authors do not test on multi-modal tasks, long-context reasoning, or workflows with tool-use beyond simple retrieval.
Single-model assumption. All LLM calls use the same model. In practice, you might want different models for different steps (e.g., a cheap model for retrieval, a strong model for synthesis). The current formulation does not address model selection per step.
Text-space search is noisy. Optimizing in natural language means the search is stochastic. Different runs can produce different workflows. The authors report some variance across seeds, though the overall trends are consistent.
No comparison against agentic approaches. FlowBot optimizes static workflows with fixed execution order. It does not compare against autonomous agents that plan and decide at runtime. This is a different paradigm, and the tradeoffs are not yet clear.
The Bigger Picture
FlowBot sits at an interesting intersection. The prompt optimization community (DSPy, TextGrad, GEPA) has gotten good at tuning prompts within fixed structures. The automated workflow community (AFlow, ADAS) has gotten good at searching over structures in code space. FlowBot bridges both by optimizing structure and prompts simultaneously, using the same mechanism (textual gradients) for both levels.
The bilevel formulation is clean. The outer loop decides what the system looks like. The inner loop decides how each piece behaves. This is how you would want it to work if you were being principled about it.
The results show that automatic induction can match human design. That is not the same as surpassing it. But it is a strong signal that the bottleneck in building LLM workflows is shifting from human creativity to data and compute. If you have the data, FlowBot-style approaches can turn that data into working pipelines without a human in the design loop.
That has implications for how agent systems get built. Today, the limiting factor is engineering time. You need someone who understands both the domain and the LLM stack to sketch a workflow, write prompts, and iterate. Tomorrow, the limiting factor may be data quality. If you can describe what success looks like with labeled examples, the system can figure out the rest.
FlowBot is not the final word on this. It is a proof of concept that the bilevel approach works, that textual backpropagation transfers from single prompts to multi-step workflows, and that discovered workflows can be sensible. The next steps are obvious: handle branching, handle model heterogeneity, scale to longer chains, and integrate tool use more deeply.
But the direction is clear. The same pattern that made neural architecture search viable, combining structure search with parameter optimization under a unified objective, works for LLM workflows too. The architecture is the prompt. The loss is task performance. The gradient is natural language. And the whole thing can be automated.
Suggested Title
Stop Hand-Crafting Your LLM Pipelines: FlowBot Discovers Them Automatically
Word Count
2,187 words (body text)
Citations
- Yu, H., Kim, Y.-B., & Kim, Y. (2026). Inducing LLM Workflows with Bilevel Optimization and Textual Gradients. arXiv:2604.26258. https://arxiv.org/abs/2604.26258
- Agrawal, A. et al. (2025). GEPA: Generating Effective Prompts Automatically. (Prompt optimization within fixed workflow structure baseline)
- Zhang, T. et al. (2024). AFlow: Automating Agentic Workflow Generation. arXiv:2410.10762. (Automated workflow generation baseline)
- Yuksekgonul, M. et al. (2025). Optimizing with TextGrad. (Textual gradient backpropagation method)
- Khattab, O. et al. (2023). DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines. (Prompt optimization framework)
- Pryzant, R. et al. (2023). Automatic Prompt Optimization with Gradient Descent and Beam Search. (Earlier textual gradient work)
- Zoph, B. & Le, Q.V. (2016). Neural Architecture Search with Reinforcement Learning. (Neural architecture search reference)
- Liu, H. et al. (2018). DARTS: Differentiable Architecture Search. (Differentiable architecture search reference)
Fact-Check Notes
- The exact benchmark numbers (Table 1, Table 3) were not fully readable from the HTML rendering of the paper. The qualitative descriptions ("outperforms on four of six benchmarks," "competitive on instruction/privacy tasks," "matches or exceeds GEPA on retrieval-heavy benchmarks") are drawn directly from the authors' descriptions of their results. A human reviewer should verify the exact numbers against the paper's tables before publishing.
- The cost comparison ($165.39 for FlowBot vs $352.46 for AFlow) is directly quoted from the paper, based on April 2026 GPT-4.1 mini pricing.
- The six-step HotpotQA workflow description is based on the paper's qualitative analysis section and Table 5. Exact step names and ordering should be verified against the paper.
- The ablation claims (both outer loop and inner loop are necessary) come from the paper's ablation discussion. The paper does not provide a separate ablation results table in the sections I could access. Verify specific ablation numbers before publishing.
- The claim that FlowBot "matches or exceeds GEPA" should be verified against Table 1's exact numbers. The paper states FlowBot "improves upon GEPA on retrieval/verification-heavy benchmarks while remaining competitive on instruction- and privacy-centric tasks."