← Latest papers
🤖 AI

FAPO: Fully Autonomous Prompt Optimization of Multi-Step LLM Pipelines

FAPO is a fully autonomous framework that optimizes multi-step LLM pipelines by iteratively evaluating, diagnosing, and refining both prompts and chain structures, achieving state-of-the-art performance across general and security-focused benchmarks by outperforming the GEPA baseline.

Original authors: Paul Kassianik, Baturay Saglam, Huaibo Zhao, Blaine Nelson, Supriti Vijay, Aman Priyanshu, Amin Karbasi

Published 2026-06-19
📖 4 min read☕ Coffee break read

Original authors: Paul Kassianik, Baturay Saglam, Huaibo Zhao, Blaine Nelson, Supriti Vijay, Aman Priyanshu, Amin Karbasi

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a team of robots working together to solve a complex puzzle. Each robot has a specific job: one finds clues, another thinks about them, and a third writes down the final answer. Sometimes, the whole team fails, but it's hard to tell which robot messed up. Did the first one miss a clue? Did the second one get confused? Or did the third one write the answer in the wrong format?

This is the problem with Multi-step LLM pipelines (complex chains of AI tasks). Traditional methods try to fix the whole team by just rewriting the instructions given to the "boss" robot (the prompt). But if the problem is actually that the team is missing a step or the robots are talking to the wrong people, just changing the instructions won't help.

Enter FAPO (Fully Autonomous Prompt Optimization). Think of FAPO as a super-smart, autonomous project manager (powered by an AI called Claude Code) that doesn't just rewrite instructions; it watches the whole team work, finds the exact bottleneck, and fixes it.

Here is how FAPO works, using simple analogies:

1. The Detective Phase (Inspection)

Instead of guessing, FAPO watches the team solve a practice puzzle. It records every move, every clue found, and every thought process. If the team gets the answer wrong, FAPO acts like a detective:

  • "Did we fail because we didn't find the right clue?" (Retrieval failure)
  • "Did we find the clue but misunderstand it?" (Reasoning failure)
  • "Did we understand it but write the answer in the wrong format?" (Formatting failure)

2. The "Fix-It-First" Rule (Prompt Edits)

FAPO follows a strict rule: Start small.
If the detective finds that the team just needs clearer instructions, FAPO rewrites the prompt (the instructions). It's like telling the robots, "Hey, look for the red box, not the blue one." It tries this first because it's the easiest fix.

3. The "Redesign" Phase (Structural Changes)

If FAPO tries rewriting the instructions over and over, but the team still fails because they are missing a crucial step (like needing a fourth robot to double-check the math), FAPO gets permission to change the team structure.

  • It might add a new robot to the team.
  • It might change the order in which the robots talk to each other.
  • It might add a "safety check" step that forces the team to follow specific rules before writing the final answer.

This is the key difference: FAPO only changes the structure of the pipeline if it proves that just changing the words (prompts) isn't enough.

4. The Safety Inspector (Guardrails)

Before FAPO makes any change, a "Safety Inspector" (another AI agent) checks the plan. This ensures FAPO doesn't accidentally delete important rules, leak private data, or break the scoring system. It's like a building inspector checking a renovation plan before the construction crew starts.

The Results: How Well Did It Work?

The paper tested FAPO against another tool called GEPA (which is like a very good editor that only rewrites instructions) across six different types of challenges, from math problems to security tasks.

  • The Scoreboard: FAPO won 15 out of 18 times.
  • The Big Wins: On the hardest tasks (like fact-checking complex stories or following strict formatting rules), FAPO didn't just tweak the instructions; it realized the team needed a new structure. In these cases, FAPO's scores jumped by huge margins (up to +33.8 percentage points better than the competition).
  • Security Tasks: FAPO also improved how well AI models could identify security vulnerabilities (like mapping software bugs to their causes), proving it works for serious, high-stakes jobs too.

The One Exception

There was one math competition (AIME) where FAPO didn't win. The authors suggest this might be because the math problems were so hard and the sample size so small that the AI got "confused" or over-fitted to the practice problems, rather than actually learning the math better.

Summary

FAPO is like a smart manager who doesn't just yell at the workers to "do better." Instead, it watches the workflow, diagnoses exactly where the process breaks, fixes the instructions first, and only if that fails, it redesigns the entire workflow to make the team more effective. It turns a messy, failing chain of AI steps into a reliable, high-performing machine.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →