From f7fbc35165e9f3a3f47af68f14b09a9281a6d7f8 Mon Sep 17 00:00:00 2001 From: BryonGo <18lkdev@gmail.com> Date: Mon, 1 Jun 2026 01:33:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20use=20effective=5Fmodel=5Ffor=5Fbudget?= =?UTF-8?q?=20instead=20of=20raw=20model=20in=20compactio=E2=80=A6=20(#243?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: use effective_model_for_budget instead of raw model in compaction_config When model is set to 'auto', self.model holds the literal string 'auto', which gets passed to the API as the model name in compaction requests. DeepSeek's API rejects 'auto' with HTTP 400 since it's not a recognized model ID. effective_model_for_budget() resolves 'auto' to the last effective model or falls back to DEFAULT_TEXT_MODEL, ensuring compaction always sends a concrete model name. * test(tui): cover auto model compaction config --------- Co-authored-by: codgo Co-authored-by: Hunter B --- crates/tui/src/tui/app.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/tui/src/tui/app.rs b/crates/tui/src/tui/app.rs index 9ff82990..9f405a40 100644 --- a/crates/tui/src/tui/app.rs +++ b/crates/tui/src/tui/app.rs @@ -4733,7 +4733,7 @@ impl App { CompactionConfig { enabled: self.auto_compact, token_threshold: self.compact_threshold, - model: self.model.clone(), + model: self.effective_model_for_budget().to_string(), ..Default::default() } } @@ -5985,10 +5985,20 @@ mod tests { #[test] fn test_compaction_config() { - let app = App::new(test_options(false), &Config::default()); + let mut app = App::new(test_options(false), &Config::default()); let config = app.compaction_config(); // Config should be valid (just checking it returns something) let _ = config.enabled; + + app.auto_model = true; + app.model = "auto".to_string(); + app.last_effective_model = None; + let config = app.compaction_config(); + assert_eq!(config.model, DEFAULT_TEXT_MODEL); + + app.last_effective_model = Some("deepseek-v4-flash".to_string()); + let config = app.compaction_config(); + assert_eq!(config.model, "deepseek-v4-flash"); } #[test]