fix: use effective_model_for_budget instead of raw model in compactio… (#2437)
* 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 <anbiaoren@gie777.com> Co-authored-by: Hunter B <hmbown@gmail.com>
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user