Coding Agents are Strong Prompt Optimizers
Organizations: Microsoft
Abstract
Search-based prompt optimizers improve prompts through iterative search: they propose edits, execute fresh rollouts, score the resulting trajectories, and retain only edits that improve a validation metric. We show that this optimization loop is unnecessary. Given only a static corpus of agent trajectories, an off-the-shelf coding agent can directly synthesize an optimized prompt, requiring neither environment access nor validation data. We call this approach Coding-Agent Skill Distillation (CASD). The key insight is reflection scope. Rather than reasoning over a small batch of trajectories at each optimization step, the coding agent writes and executes analysis code to compute corpus-wide statistics, identifies systematic failure modes, inspects representative episodes, and distills the resulting insights into behavioral rules. Across four agentic benchmarks (ALFWorld, -bench retail and telecom, and SpreadsheetBench-Verified), under matched data access, a single CASD pass outperforms GEPA, a state-of-the-art reflective prompt optimizer, on three of four benchmarks and outperforms validation-gated reflective search (SkillOpt) on all four, improving the unoptimized baseline by 16.6 percentage points on average versus 10.9 for GEPA and 5.3 for SkillOpt. Because CASD performs a single offline analysis pass rather than iterative search, producing an optimized prompt costs approximately $1.60---over cheaper than validation-gated search. Even when competing methods are granted additional validation data and unrestricted environment access, CASD remains ahead on two of four benchmarks. These results suggest that corpus-scale statistical reflection is a viable alternative to iterative search for prompt optimization.
Figures & tables
| Benchmark | Baseline | CASD (ours) | SkillOpt | GEPA |
|---|---|---|---|---|
| ALFWorld | 56.7 1.2 | 83.3 2.3 | 68.0 2.0 ‡ | 74.0 2.0 |
| retail | 32.5 2.5 | 40.0 2.5 | 38.3 10.1 | 39.2 7.2 |
| telecom | 19.2 5.2 | 39.2 8.0 | 25.8 3.8 | 17.5 4.3 |
| SSB-Verified | 39.3 3.1 | 51.3 3.1 | 38.7 2.3 | 60.7 3.1 |
| Mean gain vs. base | — | +16.6 | +5.3 | +10.9 |
| Benchmark | Baseline | CASD (ours) | SkillOpt | GEPA |
|---|---|---|---|---|
| ALFWorld | 56.7 1.2 | 83.3 2.3 | 68.0 2.0 ‡ | 74.0 2.0 |
| retail | 32.5 2.5 | 40.0 2.5 | 38.3 10.1 | 46.7 8.0 |
| telecom | 19.2 5.2 | 39.2 8.0 | 44.2 5.2 | 15.8 5.2 |
| SSB-Verified | 39.3 3.1 | 51.3 3.1 | 48.0 2.0 | 56.7 1.2 |
| ALFWorld | Retail | Telecom | SSB | Total | |
|---|---|---|---|---|---|
| CASD (ours) | 1.6 | 1.6 | 1.56 | 1.6 | 6.4 |
| GEPA | 2.1 | 1.1 | 4.5 | 0.74 | 8.4 |
| SkillOpt | 15.9 | 13.9 | 74.7 | 38.0 | 142.5 |
| Benchmark | no-think | +CASD | think | Rec. | tok ( ) |
|---|---|---|---|---|---|
| ALFWorld | 56.7 | 83.3 | 71.3 1.2 | 100% | 3.7k 0.8k |
| retail | 32.5 | 40.0 | 35.0 6.6 | 100% | 1.6k 0.6k |
| telecom | 19.2 | 39.2 | 45.0 2.5 | 78% | 2.1k 0.6k |
| SSB-Verified | 39.3 | 51.3 | 61.3 1.2 | 55% | 3.3k 0.8k |
Automatic Prompt Optimization
Automatic prompt optimization uses model or task feedback to revise instructions for stronger, more reliable language-model performance.
See all 99 papers