AutoPDL: Automatic Prompt Optimization for LLM Agents

Claudio Spiess, Mandana Vaziri, Louis Mandel, Martin Hirzel

TL;DR

AutoPDL applies automated machine learning (AutoML) to the joint optimization of high-level prompting patterns (e.g., Chain-of-Thought, ReAct, ReWOO) and low-level prompt contents (instructions and few-shot exemplars). Implemented as a source-to-source optimizer using the YAML-based Prompt Declaration Language (PDL), it outputs fully executable, human-readable agent programs that achieve accuracy gains of up to 68.9 percentage points across diverse models and tasks.

What Problem Does This Paper Address?

Getting the best performance out of Large Language Models (LLMs) requires navigating a combinatorial maze: choosing high-level orchestration patterns (Zero-Shot, Chain-of-Thought, ReAct, ReWOO), formatting instructions, and selecting effective few-shot demonstrations. Today, this process is mostly done via tedious, manual trial-and-error.

While existing prompt optimizers (such as DSPy) optimize few-shot examples or textual instructions, they operate over fixed reasoning structures and often obscure the final pipeline behind internal abstractions. Conversely, agent frameworks (like CrewAI or AutoGen) lock users into rigid ReAct-style loops with hardcoded prompts. AutoPDL bridges this gap by framing prompt and pattern discovery as an AutoML search that produces transparent, editable, and runnable code.

Methods

AutoPDL treats configuration tuning as a discrete search problem over a space $\mathcal{A} \times \mathcal{P}$:

  • Search Space Dimensions:
  • Prompting Pattern ($\mathcal{A}$): Zero-Shot, Chain-of-Thought (CoT), ReWOO, or ReAct.
  • Number of Demonstrations ($n$): Drawn from $\{0, 3, 5\}$.
  • Exemplars ($d_{\text{train}}$): Specific subsets of trajectories/examples sampled with replacement from an example bank.
  • System Prompt / Instruction: Different tool-calling system prompts (e.g., Granite Tools, LLaMA 3, Granite LLaMA).
  • Search Algorithm: AutoPDL uses Successive Halving, an incremental data allocation technique. It starts with 100 candidate configurations evaluated on a small validation slice ($v_{\text{min}} = 16$). In each iteration, it prunes the worse half of candidates while doubling the validation subset size, efficiently saving inference compute.
  • Source-to-Source Representation: Both the search space and the resulting optimal configuration are expressed in PDL (Prompt Declaration Language), a declarative, YAML-based framework. The output is directly executable code that a human can inspect, version-control, or tweak.
[Search Space YAML]  --->  [Successive Halving]  --->  [Executable PDL Program]
  - Pattern                  - Discard worst 50%        - Optimized pattern
  - # of shots               - Double val data size     - Concrete exemplars
  - Tool prompts                                        - Directly editable

Datasets

The authors evaluated AutoPDL on four standard benchmarks across mathematical reasoning, fact verification, and code generation:

  1. GSM8K: Grade-school math word problems paired with a calculator tool.
  2. GSM-Hard: A harder math dataset derived from GSM8K with large numbers. AutoPDL used GSM8K's training bank to evaluate cross-task transfer in low-resource settings.
  3. FEVER (BIG-bench variant): A fact-extraction and verification task framed as true/false, paired with a Wikipedia search API.
  4. MBPP+: Python programming problems evaluated against an expanded suite of unit tests, utilizing a Python code-execution tool.

Key Insights and Ideas

  • No "One Size Fits All" Strategy: The best prompting architecture depends heavily on the model and the task. For example, on FEVER, ReWOO excelled for Granite 13B and LLaMA 3.2 3B, while 3-shot CoT was superior for Granite 20B/34B and LLaMA 3.1 8B.
  • Agentic vs. Non-Agentic Trade-offs: While interactive tool-calling (ReAct) dominated code generation (MBPP+) due to execution feedback, non-agentic CoT or non-reactive ReWOO often performed better and faster on QA and math.
  • Cross-Dataset Transfer: When training exemplars are absent (as tested on GSM-Hard), sourcing demonstrations from a related dataset (GSM8K) was effective, yielding up to a +6.1 percentage point (pp) boost.
  • Open-to-Closed Model Transferability: Prompt programs optimized on open-weights models transferred successfully to commercial frontier models. When solutions optimized for LLaMA 3.1 70B were applied to OpenAI’s gpt-4o-mini, accuracy jumped by up to +13.1pp on GSM8K and +9.3pp on GSM-Hard.

Key Results

Evaluations across seven open models (Granite and LLaMA families, ranging from 3B to 70B parameters) revealed:

  • Accuracy Gains: Average improvements of 9.06 ± 15.3 pp over zero-shot baselines, reaching as high as +68.9pp (Granite 13B Instruct V2 on FEVER: 6.5% $\rightarrow$ 75.4%).
  • Model Scaling: Even the largest evaluated model, LLaMA 3.3 70B, saw clear benefits (+9.9pp on GSM8K using 3-shot CoT; +9.9pp on FEVER using ReWOO).
  • Code Execution: On MBPP+, ReAct loops with iterative unit-test execution delivered strong improvements for models like Granite 34B Code (+12.6pp).

Limitations and Future Work

  • Rule-Based Trajectory Synthesis: The agent demonstrations (thoughts, tool calls, and observations) were converted from standard datasets via heuristic templates rather than synthetic bootstrapping with stronger LLMs.
  • Search Space Breadth: The tool set itself was fixed per task, and the demonstration count was restricted to $\{0, 3, 5\}$ to limit token costs.
  • Future Directions: The authors suggest making tool selection a dynamic dimension of the search space, employing advanced AutoML search algorithms (e.g., Bayesian optimization or tree search), and exploring automatic trajectory bootstrapping.

Summary updated

BibTeX
@inproceedings{spiess2025autopdl,
  author = {Claudio Spiess and Mandana Vaziri and Louis Mandel and Martin Hirzel},
  title = {{AutoPDL: Automatic Prompt Optimization for LLM Agents}},
  booktitle = {AutoML Methods Track},
  year = {2025},
  url = {https://openreview.net/forum?id=CAeISyE3aR},
}

Loading related content...

Figure