Skip to main content
Every algorithm below takes a program, a set of examples and a metric, and returns the program with better text in it. With a scenario suite as the metric, one metric call is one simulated conversation, which is why the number of metric calls is the cost that matters in the table. The guided loop is listed first because it is the one to start with: it changes code and tools, and no algorithm does that.

The table

The instruction optimizers above (COPRO, MIPROv2, GEPA, SIMBA) rewrite the instructions of every predictor in the program, and on a dspy.ReAct program the instructions contain the tool descriptions, so those optimizers change the tools as well. BootstrapFewShot and BootstrapFewShotWithRandomSearch leave the instructions alone and only add demonstrations. See Optimize with DSPy.

Which one

  • Start with the guided loop. Most of the turns in a long conversation come from a tool contract or a harness setting, and an algorithm cannot change either, while one hypothesis in the guided loop costs one suite run.
  • GEPA when the metric returns text feedback. A scenario judge writes why a candidate failed, and GEPA’s reflection reads that text and proposes the next candidate from it, without you reviewing each step.
  • MIPROv2 when the metric is a number. An evaluator that returns a score with no reasoning, or a dataset with expected outputs, fits MIPROv2, and LangWatch tracks every trial of it.
  • COPRO on a small budget, when you want the instructions rewritten in a few calls and have no examples to add.
  • BootstrapFewShot when the format is the problem, meaning the instructions are right and the model gets the shape of the answer wrong.

Tracking a run

langwatch.dspy.init(experiment=..., optimizer=optimizer) records every trial of a tracked optimizer in Experiments, with the score, the instructions of each predictor and the examples it chose. For an optimizer without a tracked class, the custom optimizer page shows how to log a step yourself.
Also check: Improve your agent (the loop the algorithms run inside), DSPy visualization, Prompt optimization with Langy.
Last modified on September 4, 2026