Repository navigation
After a module is compiled, is it possible to retrieve the optimized prompt? #519
Replies: 2 comments 4 replies
|
You can always use |
|
Retrieving the optimized prompt from a compiled DSPy module is the right instinct — it's the artifact you actually care about, and being able to inspect/version/deploy it independently of the compilation framework is important for production systems. For agent systems specifically, compiled DSPy modules raise an interesting question: what's the "prompt" when the module includes tool definitions, delegation logic, and memory retrieval steps? The optimized prompt is no longer just a text string — it's a structured program that includes control flow. A few things we've found useful for this: Snapshot the full program state — not just the prompt text but the full compiled representation: few-shot examples selected, which demonstrations were kept, the reasoning patterns the optimizer converged on. Store this as a versioned artifact. Separate optimization from deployment — optimize offline, deploy the fixed compiled program. Don't re-optimize in production on every call (expensive and non-deterministic). The compiled program is the deployment artifact, like a trained model checkpoint. Version compiled programs against model versions — a compiled program optimized for Claude Sonnet may perform differently on Claude Opus. Track which model version the compilation was run against. For agent orchestration specifically, the compiled DSPy module (retrieved prompt + examples) can serve as the "skill" definition that an agent contributes to the network — other agents can invoke it without knowing the optimization process: https://blog.kinthai.ai/221-agents-multi-agent-coordination-lessons has some patterns around skill composition. Are you asking about retrieval for debugging/inspection, or for deploying to production without the full DSPy runtime? |
Uh oh!
There was an error while loading. Please reload this page.
How can I output the actual prompt that the module compiled/optimized? I'm using LLMs in typescript so I can't use the module itself.
All reactions