You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plus lm.copy(**overrides) for creating variant LMs, and dspy.context(lm=...) for thread-local temporary switching.
dspy-rs currently has global-only LM via GLOBAL_SETTINGS.lm. No per-module assignment, no config merging, no context-style overrides, and no retry/backoff on transient failures.
What's needed
Per-module LM
Predict<S> and Module should support an optional .lm field
DummyLM should share a trait with LM #77 first — extract LanguageModel trait from LM/DummyLM. Without a trait, you can't store Arc<dyn LanguageModel> in Settings or Predict.
Activity
darinkishore commentedon Feb 12, 2026
Codebase audit — current LM resolution
settings.rs— global only:SettingsstoresArc<LM>(concrete type, not trait object). No per-module, no call-time, no context-local.Predictstruct — no LM field:Dependency chain for this issue:
DummyLM should share a trait with LM #77 first — extract
LanguageModeltrait fromLM/DummyLM. Without a trait, you can't storeArc<dyn LanguageModel>in Settings or Predict.proper error handling #67 partially — retry/backoff needs typed
LmCallErrorto distinguish transient (429, 5xx, network) from permanent (401, 400) errors.Then this issue becomes:
lm: Option<Arc<dyn LanguageModel>>toPredict<S>self.lm.unwrap_or_else(|| get_lm())LM::copy(**overrides)or a builder.with_temperature(0.0)patternclient.completion()call with exponential backoff on transient errorstokio::task_local!or a scoped guard that temporarily overridesGLOBAL_SETTINGS.lmDSPy Python reference (for parity):
dspy.context(lm=...)→ thread-local temporary overridepredictor.lm = my_lm→ per-modulepredictor(question="...", lm=other_lm)→ call-timelm.copy(temperature=0.0)→ variant creationlm.num_retrieswith exponential backoff, 429/5xx are transient