Skip to main content

codetether_agent/session/helper/
defaults.rs

1//! Default model selection per provider.
2//!
3//! When a session has no explicit model configured we fall back to a
4//! sensible default for the chosen provider. These defaults only apply when
5//! the caller has not set [`SessionMetadata::model`](super::super::SessionMetadata::model).
6
7/// Return the default model ID for a given provider name.
8pub(crate) fn default_model_for_provider(provider: &str) -> String {
9    match provider {
10        "moonshotai" => "kimi-k2.5".to_string(),
11        "anthropic" => "claude-sonnet-4-20250514".to_string(),
12        "minimax" => "MiniMax-M2.5".to_string(),
13        "openai" => "gpt-4o".to_string(),
14        "google" => "gemini-2.5-pro".to_string(),
15        "local_cuda" => std::env::var("LOCAL_CUDA_MODEL")
16            .or_else(|_| std::env::var("CODETETHER_LOCAL_CUDA_MODEL"))
17            .unwrap_or_else(|_| "qwen3.5-9b".to_string()),
18        "zhipuai" | "zai" | "zai-api" => "glm-5".to_string(),
19        // OpenRouter uses model IDs like "z-ai/glm-5".
20        "openrouter" => "z-ai/glm-5".to_string(),
21        "novita" => "Qwen/Qwen3.5-35B-A3B".to_string(),
22        "github-copilot" | "github-copilot-enterprise" => "gpt-5-mini".to_string(),
23        _ => "gpt-4o".to_string(),
24    }
25}
26
27#[cfg(test)]
28mod tests {
29    use super::default_model_for_provider;
30
31    #[test]
32    fn openai_defaults_to_gpt4o() {
33        assert_eq!(default_model_for_provider("openai"), "gpt-4o");
34    }
35
36    #[test]
37    fn unknown_provider_defaults_to_gpt4o() {
38        assert_eq!(default_model_for_provider("does-not-exist"), "gpt-4o");
39    }
40
41    #[test]
42    fn zhipuai_aliases_resolve_to_glm() {
43        assert_eq!(default_model_for_provider("zai"), "glm-5");
44        assert_eq!(default_model_for_provider("zhipuai"), "glm-5");
45        assert_eq!(default_model_for_provider("zai-api"), "glm-5");
46    }
47}