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 best decomposition is unknown and worth searching, given a metric and dataset
- Deterministic parts (arithmetic, parsing, lookups) shouldn't cost an LM call
- You want the optimizer to trade accuracy against cost
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.
More from coding & agent
- Open-source MCP tool shares one memory across all local AI models, claims 99% token savings — gonzarom · 2026-10-01
- LEGO-Anything: Coding Agents Rebuild Single Images into Editable 3D Scenes — _akhaliq · 2026-10-01
- From SELECT to SYSADMIN: Critical SQL Copilot privilege escalation flaw patched by Microsoft — wunderwuzzi23 · 2026-10-01
- Magnitude: open-source inference engine that self-tunes kernels, up to 2x faster than llama.cpp — paranoidray · 2026-10-01
- Early look: Codex Plugin Extensions are cool but still rough around the edges — Angaisb_ · 2026-10-01
- Retriever AI's self-run benchmark scores 24/24 vs OpenAI Dots' 22/24 on five everyday agent tasks — quarkcarbon · 2026-10-01