From 208344ad98c4c3c232a1ff79df15a51ee8f6255e Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Sun, 24 May 2026 19:27:29 -0400 Subject: [PATCH] ai: mirror chat model on local client to prevent mid-turn model swap When the user selects a model from the picker, the local client's primary_model and vision_model now match the chat model. Prevents llama-swap exclusive mode from swapping models when describe_photo or rerank fires during an agentic turn. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/ai/insight_generator.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ai/insight_generator.rs b/src/ai/insight_generator.rs index f95c6dc..80a7627 100644 --- a/src/ai/insight_generator.rs +++ b/src/ai/insight_generator.rs @@ -3635,8 +3635,16 @@ Return ONLY the summary, nothing else."#, }; // ── local client (utility calls: rerank, describe_image, etc.) ─ + // For llamacpp: mirror the chat model selection so rerank / + // describe_image hit the same model that's already loaded — + // avoids a mid-turn model swap in llama-swap exclusive mode. let local: Box = if local_via_llamacpp { - Box::new(self.llamacpp.as_ref().unwrap().as_ref().clone()) + let mut lc = self.llamacpp.as_ref().unwrap().as_ref().clone(); + if let Some(ref m) = overrides.model { + lc.primary_model = m.clone(); + lc.set_vision_model(m.clone()); + } + Box::new(lc) } else { Box::new(self.ollama.clone()) };