In an Ask HN thread about prompt tuning, commenter dbreunig points to a different target for optimization: the code that calls the model. In DSPy 3.5.0, dspy.Flex lets GEPA propose new Python implementations while keeping the same signature, the contract for inputs and outputs.
The Flex docs show an invoice task that takes text and returns a total in cents. Without tools, the baseline asks a single dspy.Predict to return the total. GEPA can propose code that asks the model only for line items and then adds them in Python. The optimized module exposes the proposed implementation through module_src, so you can see what changed.
Proposed exercise
Sketch three ways to total synthetic invoices: a single predictor, a hand-written extract-then-sum pipeline, and a Flex candidate chosen on validation data. Use exact cents and include discounts and missing quantities in a separate final test set. Compare accuracy and model calls there after freezing all three. Keep the optimization budget separate from what it costs to process each invoice.
Caveat: the docs show what GEPA can rewrite. They do not show that the rewrite beats a hand-written baseline.
Start with GEPA feedback and held-out tests or return to the learning path.