By Sagar Shankaran, Founder of CallSphere
DSPy compiles natural-language signatures into optimized prompts and demonstrations. MIPROv2 (Bayesian optimization over instructions + few-shot exemplars) consistently delivers 10–40% quality lift over hand-written prompts on structured tasks.
Key takeaways
TL;DR — DSPy is the framework for programming, not prompting language models. In 2026 the default optimizer is MIPROv2 — Bayesian optimization over instructions and demonstrations, jointly. On structured tasks (QA, classification, extraction, multi-hop reasoning) MIPROv2 lifts quality 10–40% over hand-written prompts. Don't use it for one-shot creative tasks.
DSPy lets you define a Python module with typed input/output signatures, then compile it: an optimizer searches the space of prompt instructions and few-shot exemplars to maximize a metric you supply. The optimizer never touches model weights — the only output is a better prompt.
flowchart TD
SIG[Module signature] --> COMPILE[Compile with MIPROv2]
TRAIN[(Trainset 30-200)] --> COMPILE
METRIC[Eval metric] --> COMPILE
COMPILE --> BO[Bayesian search: instructions x demos]
BO --> CAND[Candidate prompts]
CAND --> EVAL[Score on val set]
EVAL -->|best| OPT[Optimized prompt]
OPT --> RUNTIME[Runtime module]
MIPROv2 generates data-aware instructions and demonstration-aware few-shot exemplars. COPRO is the lighter coordinate-ascent alternative; SIMBA uses stochastic mini-batches with self-reflection on failures.
CallSphere uses DSPy on the 3 highest-leverage routing modules across 6 verticals:
Across 37 agents · 90+ tools · 115+ DB tables, DSPy compilation is now part of CI — every merge re-compiles affected modules and gates on metric regression. Plans: $149 / $499 / $1,499, 14-day trial, 22% affiliate.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
import dspy
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini", api_key=KEY))
class EligibilityRouter(dspy.Signature):
"""Classify insurance plan eligibility for a given procedure."""
plan: str = dspy.InputField()
procedure: str = dspy.InputField()
decision: str = dspy.OutputField(desc="covered | needs_pa | denied")
router = dspy.ChainOfThought(EligibilityRouter)
def metric(gold, pred, trace=None):
return gold.decision == pred.decision
trainset = [...] # 60 labeled cases
optim = dspy.MIPROv2(metric=metric, auto="medium")
compiled = optim.compile(router, trainset=trainset, valset=valset)
compiled.save("eligibility_router.json")
Predict for simple, ChainOfThought for reasoning, ReAct for tools. Picking wrong wastes budget.Q: Does DSPy work with Claude or local models?
Yes — dspy.LM supports OpenAI, Anthropic, vLLM, Ollama, and any LiteLLM provider.
Q: MIPROv2 vs COPRO? MIPROv2 jointly optimizes instructions + demos with Bayesian opt; COPRO does coordinate ascent on instructions only. MIPROv2 wins on quality, COPRO on compute.
Q: How long does compilation take? 60–240 minutes typical for MIPROv2 on a 60-example trainset, depending on LM speed.
Q: Can I optimize a multi-module pipeline? Yes — DSPy compiles the whole graph. Each module's prompts and exemplars are co-optimized.
Q: When does DSPy lose to hand-prompts? One-shot creative tasks, anything without a metric, and very simple lookups. ROI is in structured pipelines.
Prompt Optimization with DSPy + MIPROv2 in 2026 ultimately resolves into one engineering question: when do you use the OpenAI Realtime API versus an async pipeline? Realtime wins on latency for live calls. Async wins on cost, retries, and structured tool reliability for callbacks and SMS flows. Most teams need both, and the routing layer between them becomes the most load-bearing piece of the stack.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Production AI agents live or die on three loops: evals, retries, and handoff state. CallSphere runs 37 agents across 6 verticals, each with its own eval suite — synthetic call transcripts replayed nightly with assertion checks on extracted entities (date, time, party size, insurance, address). Without that loop, prompt regressions ship silently and you only find out when bookings drop.
Structured tools beat free-form text every time. Our 90+ function tools all enforce JSON schemas validated server-side; if the model hallucinates an integer where a string is required, we retry with a corrective system message before falling back to a deterministic path. For long-running flows, we treat agent handoffs as a state machine — booking → confirmation → SMS — so context survives turn boundaries.
The Realtime API vs. async decision usually comes down to "is the user holding the phone right now?" If yes, Realtime; if no (callback queue, after-hours voicemail), async wins on cost-per-conversation, which we track per agent in 115+ database tables spanning all 6 verticals.
Is this realistic for a small business, or is it enterprise-only? 57+ languages are supported out of the box, and the platform is HIPAA and SOC 2 aligned, which removes most of the procurement friction in regulated verticals. For a topic like "Prompt Optimization with DSPy + MIPROv2 in 2026", that means you're not starting from scratch — you're configuring an agent template that's already been hardened across thousands of conversations.
Which integrations have to be in place before launch? Day one is integration mapping (scheduler, CRM, messaging) and prompt tuning against your top 20 real call transcripts. Day two through five is shadow-mode running, where the agent transcribes and recommends but a human still answers, so you can compare side-by-side. Go-live is the moment your eval pass-rate clears your internal bar.
How do we measure whether it's actually working? The honest answer: it scales until your tool catalog gets stale. The agent is only as good as the integrations it can actually call, so the operational discipline is keeping schemas, webhooks, and fallback paths green. The platform handles the rest — observability, retries, multi-region routing — without your team owning the GPU layer.
Want to see how this maps to your stack? Book a live walkthrough at calendly.com/sagar-callsphere/new-meeting, or try the vertical-specific demo at urackit.callsphere.tech. 14-day trial, no credit card, pilot live in 3–5 business days.
Written by
Sagar Shankaran· Founder, CallSphere
Sagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
DSPy 3.0 brings new optimizers, better caching, and first-class agent support. How to compile your prompts instead of hand-tuning them and why it pays off fast.
Learn how to design and run A/B tests for AI prompts in production. Covers experiment design, deterministic traffic splitting, metric collection, and statistical analysis for prompt optimization.
Build a feedback loop pipeline that collects user signals, categorizes feedback, analyzes failure patterns, and automatically updates prompts and retrieval to improve AI agent performance over time.
Eight practical strategies for improving LLM prompt consistency — from prompt decomposition and few-shot examples to temperature tuning and output format specification.
Where Claude Code, MCP, and multi-agent systems are taking GTM engineering next, and how to prepare your team now for standing and multi-agent workflows.
Where Claude Cowork and the Claude agent ecosystem are heading next — standing agents, MCP, skills as a moat — and the concrete moves to prepare your team now.
© 2026 CallSphere LLC. All rights reserved.