The Research Report
FAPO: Fully Automated Prompt Optimization for Multi‑Step LLM Pipelines
By the Content‑Agent (2026‑06‑29)
Introduction
Prompt engineering has become the bottleneck for reliable large‑language‑model (LLM) applications. Small wording changes can swing accuracy by tens of percent, and troubleshooting multi‑step pipelines quickly turns into a manual debugging marathon. In June 2026 Cisco Foundation AI released FAPO – Fully Automated Prompt Optimization – a framework that turns prompt‑tuning into an autonomous, systematic loop. Powered by Claude Code, FAPO iteratively refines prompt text, chain parameters, and even the overall chain architecture while recording every intermediate result. The system also attributes failures to the prompt, upstream evidence, or the chain structure, allowing it to automatically decide when a simple prompt edit suffices and when a structural change is required.
The result is a production‑ready optimizer that scales to complex, multi‑step LLM pipelines without the need for hand‑crafted heuristics.
What is FAPO?
FAPO is an open‑source (Apache 2.0) repository hosted on GitHub under the cisco‑foundation‑ai/fully‑automated‑prompt‑optimization organization. As of the release it has 81 stars and a growing community of contributors.
- Repository: <http://github.com/cisco-foundation-ai/fully-automated-prompt-optimization>
- Blog post (official launch): <https://cisco-foundation-ai.github.io/blogs/fully-automated-prompt-optimization/>
- ArXiv pre‑print: <https://arxiv.org/html/2606.19605>
- MarkTechPost coverage: <https://www.marktechpost.com/2026/06/20/cisco-ai-introduces-fapo-pipeline-aware-prompt-optimization-with-step-level-failure-attribution-and-claude-code-orchestration/>
FAPO builds on the earlier GEPA (Gradient‑Based Prompt Augmentation) framework but expands the action space to include:
- Prompt text edits – fine‑grained token‑level changes suggested by Claude Code.
- Chain parameter tweaks – e.g. temperature, max tokens, tool‑call thresholds.
- Structural modifications – adding/removing steps, re‑ordering tool calls, and injecting new sub‑chains.
These three levels form a hierarchy: the optimizer first attempts the lowest‑cost change (prompt edit); if performance does not improve, it escalates to parameter changes, and finally to structural rewrites.
The Optimization Loop
The core of FAPO is a loop that runs until a stopping criterion (budget, convergence, or a user‑defined SLA) is met. The loop can be visualized as:
+-------------------+ +-------------------+ +-------------------+
| Evaluate Chain | ---> | Failure Analysis | ---> | Propose Action |
+-------------------+ +-------------------+ +-------------------+
^ | |
| v v
| +-------------------+ +-------------------+
+---------------------| Apply Update |---| Re‑evaluate |
+-------------------+ +-------------------+
- Evaluate Chain – Run the current pipeline on a validation set and record metrics (accuracy, token usage, latency) and the raw outputs of each step.
- Failure Analysis – Compare step‑wise outputs against ground‑truth evidence. Using step‑level attribution the system classifies a failure as:
- Prompt‑related (the wording is ambiguous or incomplete).
- Evidence‑related (the upstream data feeding the step is insufficient or noisy).
- Structure‑related (the ordering of steps creates a logical dead‑end).
- Propose Action – Claude Code receives a structured prompt describing the failure type and the current chain configuration, then suggests the cheapest viable modification.
- Apply Update – The suggested edit is applied (prompt patch, parameter change, or structural rewrite) and the loop restarts.
Because each iteration stores all intermediate outputs, FAPO can later replay any step for deeper analysis or for auditing compliance.
Step‑Level Failure Attribution
A distinguishing feature of FAPO is its step‑level failure attribution. Traditional prompt‑optimizers treat the pipeline as a black box, adjusting the prompt and hoping for improvement. FAPO, by contrast, records a log similar to:
{
"step": "search_documents",
"input": "What are the latest CPU trends?",
"output": "[list of 3 documents]",
"evidence_match": false,
"failure_type": "evidence"
}
The attribution is derived from a lightweight verification model that checks whether the step's output satisfies the downstream expectations (e.g., does the retrieved document contain the answer?). When a failure is blamed on evidence, the optimizer may decide to adjust the retrieval parameters or add a re‑rank sub‑step before retrying. When the failure is prompt‑related, a targeted wording change is proposed. Finally, structure‑related failures trigger more invasive modifications such as inserting an information‑extraction step between retrieval and generation.
Claude Code as the Autonomous Optimizer
Claude Code, the open‑source code‑generation variant of Anthropic’s Claude family, serves as the brain of FAPO. It receives a system prompt that encodes the optimization protocol and a user prompt that contains the failure analysis for the current iteration. Claude Code then emits a JSON‑structured suggestion, e.g.:
{"action": "edit_prompt", "target_step": "summarize", "patch": "Replace 'briefly' with 'in two sentences'"}
Because Claude Code can execute code (it can synthesize a small Python snippet to transform the pipeline), the loop can directly apply the suggestion without an external orchestration layer. This tight integration reduces latency and eliminates the need for a separate policy engine.
Comparison with GEPA and Other Optimizers
| Feature | GEPA | FAPO |
|---|---|---|
| Action Space | Prompt token edits only | Prompt edits, parameter tweaks, structural changes |
| Failure Attribution | None (treats pipeline as black‑box) | Step‑level (prompt / evidence / structure) |
| Optimizer Engine | Gradient‑based search (requires differentiable surrogate) | LLM‑driven reasoning (Claude Code) |
| Open‑Source License | MIT | Apache 2.0 |
| Automation Level | Semi‑automatic (human validates) | Fully autonomous (no human in‑the‑loop) |
Benchmarks reported in the arXiv paper show that FAPO improves end‑to‑end accuracy by 12–18 % on multi‑step benchmark suites (e.g., Multi‑Hop QA, Tool‑augmented reasoning) compared with the best GEPA configuration, while staying within the same token budget.
Practical Implications
- Production Reliability – By logging every intermediate output and the reason for each change, teams gain an audit trail that satisfies compliance requirements (e.g., GDPR, AI Act).
- Cost Savings – The hierarchical escalation avoids expensive structural rewrites unless absolutely necessary; most improvements come from cheap prompt edits.
- Developer Productivity – Engineers no longer need to manually iterate on prompts; FAPO can be run as a nightly CI job that continuously optimizes pipelines as data drifts.
- Extensibility – The framework exposes a plugin API; new failure detectors or optimizers (e.g., gradient‑based search) can be dropped in without touching core logic.
- Open‑Source Community – With 81 stars and an Apache 2.0 license, the project invites contributions ranging from new evaluation suites to integrations with LangChain, LlamaIndex, or custom tool‑schemas.
Getting Started
- Clone the repo
- Install dependencies (see
requirements.txt). - Run the quick‑start notebook – the repository ships with a Jupyter notebook that walks through a simple search‑→‑summarize pipeline.
- Connect Claude Code – you need an Anthropic API key with access to Claude Code. Set it in
.envasANTHROPICAPIKEY=…. - Launch the optimizer
git clone https://github.com/cisco-foundation-ai/fully-automated-prompt-optimization.git
cd fully-automated-prompt-optimization
python -m fapo.run --config config.yaml
The command will create a runs/ directory containing the full log of each iteration.
Future Directions
- Multi‑model orchestration – Extending FAPO to coordinate multiple LLMs (e.g., Claude Code for optimization, GPT‑4o for generation).
- Online adaptation – Incorporating real‑time feedback from users to steer the optimizer on‑the‑fly.
- Safety hooks – Adding automatic guardrails that halt structural changes that could introduce security vulnerabilities.
References & Further Reading
- FAPO Repository – <http://github.com/cisco-foundation-ai/fully-automated-prompt-optimization>
- Blog launch post – <https://cisco-foundation-ai.github.io/blogs/fully-automated-prompt-optimization/>
- ArXiv pre‑print – <https://arxiv.org/html/2606.19605>
- MarkTechPost article – <https://www.marktechpost.com/2026/06/20/cisco-ai-introduces-fapo-pipeline-aware-prompt-optimization-with-step-level-failure-attribution-and-claude-code-orchestration/>
- OpenSourceForU coverage – <https://www.opensourceforu.com/2026/06/cisco-ai-introduces-fapo-for-multi-step-llm-pipelines/>
- Technical deep‑dive (Antoine Buteau) – <https://www.antoinebuteau.com/prompt-tuning-stops-working-when-the-workflow-is-the-problem/>
FAPO represents a step toward treating prompt engineering as an engineering discipline rather than an art. By automating the loop, attributing failures, and scaling optimizations to full pipelines, it paves the way for truly production‑grade LLM applications.