Automatic prompt optimization searches for reusable instructions and examples that make an LLM program perform better. It runs candidate versions on labeled tasks, evaluates their outputs, and uses the results to choose what to try or keep. The underlying model weights stay fixed. The result is a changed program configuration that can answer future requests, rather than another attempt at answering just today's question.
DSPy is a Python framework for building these programs from prompted modules with defined inputs and outputs. An open DSPy feature request asks for failure reasons to guide MIPROv2's instruction proposals, exposing a practical distinction: a score can tell a search which candidate performed better without telling it how to repair the loser.
How do examples, scores, and failure feedback become better prompts? We will follow three DSPy optimizers along one axis: how execution evidence influences the next candidate.
BootstrapFewShotWithRandomSearch turns successful executions into demonstrations, tries different demonstration configurations, and keeps the best-scoring program.
MIPROv2 proposes instructions using information about the program and its examples, then uses scores to search combinations of instructions and demonstrations across modules.
GEPA uses execution traces and diagnostic feedback to propose new instructions. It can keep a candidate useful for further exploration even when that candidate has a lower average score.
These are different ways to search prompt configurations. Demonstrations and instructions are separate things they can change, so the methods can also complement each other.
“The answer was wrong” can reject a demonstration, lower a configuration's ranking, or prevent an edit from being accepted. “The answer used the v1 passage even though the question asks about v2” supplies additional information for writing a repair. That diagnosis is valuable only if it is accurate and the revised program survives evaluation. More detailed feedback does not remove the need for a score.
Our common program will rewrite documentation questions, retrieve passages, then answer with evidence. We will inspect the prompt changes, the candidate comparisons, and the work these searches add. The numerical examples explain decisions, not a quality ranking between optimizers.
Contents
The program and the search space
Bootstrap successful executions into demonstrations
Search instructions and demonstrations together
Use failure feedback to revise instructions
Keep useful alternatives without deploying an ensemble
Choose a search and count its cost




