The AI ecosystem moves fast. DSPy’s job is to allow you to define your tasks with stable Signatures, then easily implement them with the best components currently available.
Since its introduction in 2023, DSPy’s Signature interface hasn’t changed even as AI accelerated dramatically, and many 2022 programs still work on today’s language models. Models learned to reason, use tools, and code. Optimization has grown from selecting few-shot examples to fine-tuning, prompt optimization, code rewrites, and decision model threshold tuning. Through all of it, Signatures have remained shelf-stable contracts that describe what we want to do.
DSPy 3.5 cleans up and modernizes some of the cruft we’ve accumulated over these years. It isn’t our flashiest release and contains a few breaking changes, but as an early enterprise tester commented, “3.5 solves all my problems getting DSPy into production.”
Faster & Lighter with Fewer Dependencies
LiteLLM is now an optional dependency. DSPy calls providers using the lightweight, extensible lm15 engine. OpenAI’s Python library is now optional as well. Startup is dramatically faster and less memory is required.
LiteLLM has been an essential library as DSPy grew, and users can continue to use it by installing dspy[litellm].
As a part of the transition to LM15, you now call LMs with a typed Request and get back a Response object. Adding this structure will make it much easier and more flexible for people to implement and customize any logic required to call your LMs.
See the Custom LM Engines tutorial for more information.
Cleaned Up Core Modules
There are now four core modules: Predict, ReAct, RLM, and Flex. ReAct and RLM now share a common history system, with better prompt caching, and common image support.
Signatures with image inputs run cleanly on all modules. ReAct and RLM both return their run as prediction.history, which you can inspect or pass back to continue with a follow-up. RLM loses its “experimental” status, as does ReActV2, which is now just ReAct.
The shift to the improved ReAct is a breaking change for people calling prediction.trajectory. Inspect prediction.history.messages instead. The ReAct migration guide covers the other changes.
XML is Now the Default Adapter
Adapters format and parse LM calls, and this decision was not taken lightly. We tested this switch across many models, of various sizes and families, against our internal tests and benchmarks to ensure this change improved reliability while not affecting performance.
For smaller models especially, the XMLAdapter delivers more reliable structured outputs, clean code extraction, and parses over common model quirks.
Faster Interpreters
The real DSPy now runs inside the Deno sandbox, replacing a stand-in that built and ran predictors on the host. Sandboxes start from a precompiled standard library and a cached memory snapshot with DSPy already imported.
The optional dspy.InterpreterPool makes Flex calls 94% faster, for about 400 MB of RAM per pooled sandbox.
Additional Features
- Decisions for Images. Decision models gain bounding boxes and image inputs, and they now run on lm15.
dspy.experimental.TypeSafeis removed: use an ordinarydspy.LMinstead. - RLMs can run DSPy sub-programs. Code in RLM’s sandbox can now
import dspyand build its own typed modules, so a run can delegate to adspy.Predictsub-agent, not only rawllm_queryprompts. - Images in RLM & Flex.
dspy.Imagevalues now cross into RLM’s sandbox as real images, so generated code can crop or inspect them withto_pil()and pass them tollm_query. Pillow ships in the sandbox by default.
There are more details in the release notes, including migration tips for a few behaviors.
We’re incredibly excited about DSPy 3.5. It sets the table for the work that will arrive in 4.0. Give it a try today:
pip install -U dspy