DSPy Introduces Flex: Letting LLMs Optimize Code Directly, Cutting LLM Calls by 75%
dbreunig · x · 2026-08-06
The prompt optimization framework DSPy has introduced Flex, a new module that allows optimizers like GEPA to rewrite and optimize a program's Python code directly, rather than just tweaking prompts.
Key Highlights:
- Code-Level Optimization: Leveraging modern LLMs' coding capabilities, Flex exposes the program's source code to the optimizer, enabling the model to decompose tasks and write helper functions for improvements.
- Seamless Integration: Developers can enable it by simply swapping dspy.Predict with dspy.Flex. Prior to optimization, it behaves identically to a standard module.
- Massive Efficiency Gains: In testing, Flex improved task accuracy from 90% to 95% while reducing LLM calls by 75%.
The module was implemented by Michael Isaac, a PhD student at Carnegie Mellon University, during his internship at cmpnd.
Related event: DSPy's Flex Optimizes Both Code and Prompts, Cutting LLM Calls by 75%(4 posts)→
More from coding & agent
- Ant's Ling-3.0-flash Hits API: 124B Params for Low-Cost Agents — rohanpaul_ai · 2026-08-06
- Okta Launches AI Blueprint Tool to Assess Agent Security Architecture — ChuckDBrooks · 2026-08-06
- Microsoft Exec Advises Internal Devs to Default to OpenAI GPT-5.6 — jxnlco · 2026-08-06
- Rethinking WebRTC: What Architecture Decisions Need Updates for the Human-to-AI Era? — juberti · 2026-08-06
- Three Platforms Offer DeepSeek V4 Flash at One-Sixth of Official Pricing — oran_ge · 2026-08-06
- Hermes Agent Update: Now Integrates Bittensor Subnet 95 — markjeffrey · 2026-08-06