Release2026-08-06

cmpnd and DSPy introduced Flex, a component that lets an automatic optimizer rewrite the program's own source code rather than only its written instructions. On a task deciding whether two business listings describe the same place, the rewritten program was more accurate, cheaper and faster than the original because most cases were settled by ordinary code instead of a model call. Code written by the model runs in a sandbox and never in the host process by default.

What changed

DSPy optimizers could only rewrite a program's instructions or pick examples, not the program's own code.

What it unlocks

Letting an optimizer rewrite the source code of a task module, so easy cases are settled by plain Python and the model is called only for ambiguous ones.

  • accuracy 90.4% baseline to 95.0% with Flex
  • $0.98 to $0.70 per thousand records
  • 75% fewer model calls
  • at highest penalty setting: $0.01 per thousand records, 92.1% accuracy
  • SWE-bench Pro pilot: 0 of 12 to 4 of 12 issues resolved

What you need to act on it

  • DSPy
  • a strong model used as the rewriting model, plus a cheaper model to run the program
  • a metric and labelled training data

Send this to someone who needs it

Shares the story and its sources. Nothing about you.

What does this mean for your job?

This is the story as everyone gets it. Once a week we send you the version written for your role — what changed, why it matters for the work you actually do, and one thing to try. Free while we tune it.