DSPy's Flex lets optimizers rewrite your pipeline code, not just prompts

lateinteraction · x · 2026-10-01

DSPy introduces dspy.Flex, a new primitive whose implementation is optimizable code rather than a fixed prompt. Constructed from a signature, Flex starts as a thin baseline, but optimizers like dspy.GEPA can rewrite the module's entire source: splitting the task into multiple predictors, folding deterministic steps into plain Python, and authoring helper functions.

Use it when:

The docs include a basic usage example configured with openai/gpt-5. It's a notable step toward treating program structure itself as an optimizable parameter in LLM pipelines.

Original post →

More from coding & agent

coding & agent channel →