Skip to main content

vtcode_config/models/model_id/
capabilities.rs

1use crate::models::{Provider, ProviderModelSupport};
2
3use super::ModelId;
4
5mod capability_generated {
6    include!(concat!(env!("OUT_DIR"), "/model_capabilities.rs"));
7}
8
9/// Catalog metadata generated from `docs/models.json`.
10#[derive(Clone, Copy, Debug, PartialEq)]
11pub struct ModelPricing {
12    pub input: Option<f64>,
13    pub output: Option<f64>,
14    pub cache_read: Option<f64>,
15    pub cache_write: Option<f64>,
16}
17
18#[derive(Clone, Copy, Debug, PartialEq)]
19pub struct ModelCatalogEntry {
20    pub(crate) provider: &'static str,
21    id: &'static str,
22    pub display_name: &'static str,
23    pub description: &'static str,
24    pub context_window: usize,
25    max_output_tokens: Option<usize>,
26    pub reasoning: bool,
27    pub reasoning_efforts: &'static [&'static str],
28    pub is_pro: bool,
29    pub lightweight_model: Option<&'static str>,
30    pub tool_call: bool,
31    pub vision: bool,
32    pub input_modalities: &'static [&'static str],
33    pub caching: bool,
34    pub structured_output: bool,
35    pub supports_sampling: bool,
36    pub supports_logprobs: bool,
37    pub prompt_cache_ttl: Option<&'static str>,
38    pub prompt_contract: Option<&'static str>,
39    pub pricing: ModelPricing,
40}
41
42fn catalog_provider_key(provider: &str) -> &str {
43    if provider.eq_ignore_ascii_case("google") || provider.eq_ignore_ascii_case("gemini") {
44        "gemini"
45    } else if provider.eq_ignore_ascii_case("openai") {
46        "openai"
47    } else if provider.eq_ignore_ascii_case("anthropic") {
48        "anthropic"
49    } else if provider.eq_ignore_ascii_case("deepseek") {
50        "deepseek"
51    } else if provider.eq_ignore_ascii_case("meta") || provider.eq_ignore_ascii_case("meta-ai") {
52        "meta"
53    } else if provider.eq_ignore_ascii_case("openrouter") {
54        "openrouter"
55    } else if provider.eq_ignore_ascii_case("ollama") {
56        "ollama"
57    } else if provider.eq_ignore_ascii_case("lmstudio") {
58        "lmstudio"
59    } else if provider.eq_ignore_ascii_case("llamacpp") || provider.eq_ignore_ascii_case("llama.cpp") {
60        "llamacpp"
61    } else if provider.eq_ignore_ascii_case("moonshot") {
62        "moonshot"
63    } else if provider.eq_ignore_ascii_case("zai") {
64        "zai"
65    } else if provider.eq_ignore_ascii_case("minimax") {
66        "minimax"
67    } else if provider.eq_ignore_ascii_case("huggingface") {
68        "huggingface"
69    } else if provider.eq_ignore_ascii_case("stepfun") {
70        "stepfun"
71    } else if provider.eq_ignore_ascii_case("evolink") {
72        "evolink"
73    } else if provider.eq_ignore_ascii_case("poolside") {
74        "poolside"
75    } else if provider.eq_ignore_ascii_case("xai") {
76        "xai"
77    } else if provider.eq_ignore_ascii_case("nvidia") {
78        "nvidia"
79    } else if provider.eq_ignore_ascii_case("merge-gateway") {
80        "merge-gateway"
81    } else if provider.eq_ignore_ascii_case("vercel") || provider.eq_ignore_ascii_case("vercel-ai-gateway") {
82        "vercel"
83    } else {
84        provider
85    }
86}
87
88fn capability_provider_key(provider: Provider) -> &'static str {
89    match provider {
90        Provider::Gemini => "gemini",
91        Provider::OpenAI => "openai",
92        Provider::Anthropic => "anthropic",
93        Provider::Copilot => "copilot",
94        Provider::DeepSeek => "deepseek",
95        Provider::Meta => "meta",
96        Provider::OpenRouter => "openrouter",
97        Provider::Ollama => "ollama",
98        Provider::OllamaCloud => "ollama-cloud",
99        Provider::LmStudio => "lmstudio",
100        Provider::LlamaCpp => "llamacpp",
101        Provider::Moonshot => "moonshot",
102        Provider::ZAI => "zai",
103        Provider::Minimax => "minimax",
104        Provider::MiMo => "mimo",
105        Provider::Mistral => "mistral",
106        Provider::HuggingFace => "huggingface",
107        Provider::OpenCodeZen => "opencode-zen",
108        Provider::OpenCodeGo => "opencode-go",
109        Provider::Qwen => "qwen",
110        Provider::StepFun => "stepfun",
111        Provider::Evolink => "evolink",
112        Provider::Poolside => "poolside",
113        Provider::XAI => "xai",
114        Provider::NVIDIA => "nvidia",
115        Provider::MergeGateway => "merge-gateway",
116        Provider::Vercel => "vercel",
117    }
118}
119
120fn catalog_lookup_id<'a>(provider: &str, id: &'a str) -> &'a str {
121    let provider_key = catalog_provider_key(provider);
122    if provider_key == "evolink"
123        && let Some((prefix, model_id)) = id.split_once('/')
124        && prefix.eq_ignore_ascii_case(provider_key)
125    {
126        // Evolink namespaces its ModelId values to avoid collisions with
127        // first-class providers, while its catalog stores the upstream model
128        // id that the gateway receives (for example, `deepseek-v4-pro`).
129        return model_id;
130    }
131    id
132}
133
134fn generated_catalog_entry(provider: &str, id: &str) -> Option<ModelCatalogEntry> {
135    let provider_key = catalog_provider_key(provider);
136    let lookup_id = catalog_lookup_id(provider_key, id);
137    // Exact match wins so gateway providers that store prefixed IDs
138    // (`merge-gateway`/`vercel` keep `openai/gpt-5.6-luna`) keep working.
139    // Fall back to stripping a provider-prefixed request model
140    // (`openai/gpt-5.6-luna` on provider `openai` stores `gpt-5.6-luna`).
141    // The strip is provider-scoped (prefix must equal the provider key) so an
142    // unrelated prefix (`other-org/gpt-5.6-luna`) does not resolve to the bare
143    // model's capabilities. Without this, reasoning-effort and context
144    // lookups miss and the harness omits the effort with an empty
145    // `supported:` diagnostic.
146    let entry = capability_generated::metadata_for(provider_key, lookup_id).or_else(|| {
147        lookup_id
148            .split_once('/')
149            .filter(|(prefix, _)| prefix.eq_ignore_ascii_case(provider_key))
150            .and_then(|(_, rest)| capability_generated::metadata_for(provider_key, rest))
151    });
152    entry.map(|entry| ModelCatalogEntry {
153        provider: entry.provider,
154        id: entry.id,
155        display_name: entry.display_name,
156        description: entry.description,
157        context_window: entry.context_window,
158        max_output_tokens: entry.max_output_tokens,
159        reasoning: entry.reasoning,
160        reasoning_efforts: entry.reasoning_efforts,
161        is_pro: entry.is_pro,
162        lightweight_model: entry.lightweight_model,
163        tool_call: entry.tool_call,
164        vision: entry.vision,
165        input_modalities: entry.input_modalities,
166        caching: entry.caching,
167        structured_output: entry.structured_output,
168        supports_sampling: entry.supports_sampling,
169        supports_logprobs: entry.supports_logprobs,
170        prompt_cache_ttl: entry.prompt_cache_ttl,
171        prompt_contract: entry.prompt_contract,
172        pricing: ModelPricing {
173            input: entry.pricing.input,
174            output: entry.pricing.output,
175            cache_read: entry.pricing.cache_read,
176            cache_write: entry.pricing.cache_write,
177        },
178    })
179}
180
181pub fn model_catalog_entry(provider: &str, id: &str) -> Option<ModelCatalogEntry> {
182    generated_catalog_entry(provider, id)
183}
184
185pub fn supported_models_for_provider(provider: &str) -> Option<&'static [&'static str]> {
186    capability_generated::models_for_provider(catalog_provider_key(provider))
187}
188
189pub fn catalog_provider_keys() -> &'static [&'static str] {
190    capability_generated::PROVIDERS
191}
192
193impl ModelId {
194    fn generated_capabilities(&self) -> Option<ModelCatalogEntry> {
195        generated_catalog_entry(capability_provider_key(self.provider()), &self.as_str())
196    }
197
198    /// Preferred built-in lightweight sibling or lower-tier fallback for this model.
199    pub fn preferred_lightweight_variant(&self) -> Option<Self> {
200        let target_id = self.generated_capabilities()?.lightweight_model?;
201        Self::all_models().into_iter().find(|candidate| {
202            candidate != self && candidate.provider() == self.provider() && candidate.as_str() == target_id
203        })
204    }
205
206    /// Attempt to find a non-reasoning variant for this model.
207    pub fn non_reasoning_variant(&self) -> Option<Self> {
208        if let Some(meta) = self.openrouter_metadata() {
209            if !meta.reasoning {
210                return None;
211            }
212
213            let vendor = meta.vendor;
214            let mut candidates: Vec<Self> = Self::openrouter_vendor_groups()
215                .into_iter()
216                .find(|(candidate_vendor, _)| *candidate_vendor == vendor)
217                .map(|(_, models)| {
218                    models
219                        .iter()
220                        .filter(|&candidate| candidate != self)
221                        .filter(|&candidate| {
222                            candidate.openrouter_metadata().map(|other| !other.reasoning).unwrap_or(false)
223                        })
224                        .cloned()
225                        .collect()
226                })
227                .unwrap_or_default();
228
229            if candidates.is_empty() {
230                return None;
231            }
232
233            candidates.sort_by_key(|candidate| {
234                candidate
235                    .openrouter_metadata()
236                    .map(|data| (!data.efficient, data.display))
237                    .unwrap_or((true, ""))
238            });
239
240            return candidates.into_iter().next();
241        }
242
243        self.preferred_lightweight_variant()
244            .filter(|candidate| !candidate.is_reasoning_variant())
245    }
246
247    /// Check if this is a "flash" variant (optimized for speed)
248    pub fn is_flash_variant(&self) -> bool {
249        matches!(
250            self,
251            ModelId::Gemini38Flash
252                | ModelId::MergeGatewayGoogleGemini38Flash
253                | ModelId::VercelGoogleGemini38Flash
254                | ModelId::VercelDeepseekFlash
255                | ModelId::VercelOpenAiGpt56Luna
256                | ModelId::VercelAnthropicClaudeHaiku45
257                | ModelId::ClaudeHaiku55
258                | ModelId::MergeGatewayAnthropicClaudeHaiku4520251001
259                | ModelId::MergeGatewayAnthropicClaudeHaiku55
260                | ModelId::StepFun37Flash
261                | ModelId::MergeGatewayDeepseekFlash
262                | ModelId::DeepSeekFlash
263                | ModelId::OllamaDeepSeekV41FlashCloud
264                | ModelId::ZaiGlm53Flash
265                | ModelId::ZaiGlm53Flashx
266                | ModelId::OllamaGlm53FlashCloud
267                | ModelId::OllamaMinimaxM31FlashCloud
268                | ModelId::MergeGatewayZaiGlm53Flash
269                | ModelId::MergeGatewayZaiGlm53Flashx
270                | ModelId::HuggingFaceGlm53FlashTogether
271                | ModelId::MiMoV26Flash
272                | ModelId::MergeGatewayXiaomimimoMimoV26Flash
273                | ModelId::MinimaxM31Flash
274                | ModelId::MergeGatewayMinimaxM31Flash
275                | ModelId::OpenRouterMinimaxM31FlashFree
276        )
277    }
278
279    /// Check if this is a "pro" variant (optimized for capability)
280    pub fn is_pro_variant(&self) -> bool {
281        self.generated_capabilities().is_some_and(|entry| entry.is_pro)
282    }
283
284    /// Check if this is an optimized/efficient variant
285    pub fn is_efficient_variant(&self) -> bool {
286        if let Some(meta) = self.openrouter_metadata() {
287            return meta.efficient;
288        }
289        matches!(
290            self,
291            ModelId::Gemini38Flash
292                | ModelId::MergeGatewayGoogleGemini38Flash
293                | ModelId::Gemini4Hydrogen
294                | ModelId::MergeGatewayGoogleGemini4Hydrogen
295                | ModelId::GPT56Luna
296                | ModelId::GPT6Luna
297                | ModelId::MergeGatewayOpenAIGpt56Luna
298                | ModelId::MergeGatewayOpenAIGpt6Luna
299                | ModelId::CopilotGPT54Mini
300                | ModelId::ClaudeHaiku55
301                | ModelId::MergeGatewayAnthropicClaudeHaiku55
302                | ModelId::DeepSeekFlash
303                | ModelId::OllamaDeepSeekV41FlashCloud
304                | ModelId::MergeGatewayDeepseekFlash
305                | ModelId::MetaMuseEmber10
306                | ModelId::MergeGatewayMinimaxH3
307                | ModelId::MiMoV26Flash
308                | ModelId::ZaiGlm53Flash
309                | ModelId::ZaiGlm53Flashx
310                | ModelId::OllamaGlm53FlashCloud
311                | ModelId::OllamaMinimaxM31FlashCloud
312                | ModelId::MergeGatewayZaiGlm53Flash
313                | ModelId::MergeGatewayZaiGlm53Flashx
314                | ModelId::HuggingFaceGlm53FlashTogether
315                | ModelId::VercelDeepseekFlash
316                | ModelId::MergeGatewayXiaomimimoMimoV26Flash
317                | ModelId::MinimaxM31Flash
318                | ModelId::MergeGatewayMinimaxM31Flash
319                | ModelId::OpenRouterMinimaxM31FlashFree
320        )
321    }
322
323    /// Check if this is a top-tier model
324    pub fn is_top_tier(&self) -> bool {
325        if let Some(meta) = self.openrouter_metadata() {
326            return meta.top_tier;
327        }
328        matches!(
329            self,
330            ModelId::Gemini38Flash
331                | ModelId::MergeGatewayGoogleGemini38Flash
332                | ModelId::Gemini4Argon
333                | ModelId::Gemini4Carbon
334                | ModelId::Gemini4Hydrogen
335                | ModelId::MergeGatewayGoogleGemini4Argon
336                | ModelId::MergeGatewayGoogleGemini4Carbon
337                | ModelId::MergeGatewayGoogleGemini4Hydrogen
338                | ModelId::GPT62Astra
339                | ModelId::GPT62Sol
340                | ModelId::GPT6Astra
341                | ModelId::GPT6Sol
342                | ModelId::GPT61Sol
343                | ModelId::GPT56Sol
344                | ModelId::MergeGatewayOpenAIGpt56Sol
345                | ModelId::MergeGatewayOpenAIGpt56Terra
346                | ModelId::MergeGatewayOpenAIGpt56Luna
347                | ModelId::MergeGatewayOpenAIGpt62Astra
348                | ModelId::MergeGatewayOpenAIGpt62Sol
349                | ModelId::MergeGatewayOpenAIGpt6Astra
350                | ModelId::MergeGatewayOpenAIGpt6Sol
351                | ModelId::MergeGatewayOpenAIGpt61Sol
352                | ModelId::MergeGatewayOpenAIGpt61Terra
353                | ModelId::MergeGatewayOpenAIGpt6Luna
354                | ModelId::ClaudeSonnet5
355                | ModelId::ClaudeSonnet55
356                | ModelId::ClaudeFable5
357                | ModelId::ClaudeFable51
358                | ModelId::ClaudeFable52
359                | ModelId::ClaudeOpus5
360                | ModelId::ClaudeOpus55
361                | ModelId::MistralLarge4
362                | ModelId::OpenCodeGoGlm53
363                | ModelId::MiMoV26Pro
364                | ModelId::MiMoV26ProUltraspeed
365                | ModelId::OpenCodeGoMinimaxM3
366                | ModelId::MergeGatewayDeepseekFlash
367                | ModelId::VercelDeepseekFlash
368                | ModelId::MetaMuseSpark13
369                | ModelId::MetaMuseSpark13Contributor
370                | ModelId::MetaMuseWonder10
371                | ModelId::MetaMuseWonderFull10
372                | ModelId::ZaiGlm53
373                | ModelId::ZaiGlm53Flash
374                | ModelId::ZaiGlm53Flashx
375                | ModelId::MergeGatewayZaiGlm53Flash
376                | ModelId::MergeGatewayZaiGlm53Flashx
377                | ModelId::HuggingFaceGlm53FlashTogether
378                | ModelId::HuggingFaceGlm53Together
379                | ModelId::HuggingFaceMinimaxM3Novita
380                | ModelId::StepFun5Preview
381                | ModelId::OpenRouterMoonshotaiKimiK3
382                | ModelId::MoonshotKimiK31Pro
383                | ModelId::MoonshotKimiK3
384                | ModelId::MergeGatewayMoonshotKimiK3
385                | ModelId::MergeGatewayMoonshotKimiK31Pro
386                | ModelId::OllamaGlm53Cloud
387                | ModelId::OllamaGlm53FlashCloud
388                | ModelId::OllamaDeepSeekV41FlashCloud
389                | ModelId::OllamaMistralLarge4Cloud
390                | ModelId::OllamaMuseSparkOpenCloud
391                | ModelId::XaiGrok46
392                | ModelId::XaiGrok47
393                | ModelId::MergeGatewayXaiGrok46
394                | ModelId::MergeGatewayXaiGrok47
395                | ModelId::VercelSpacexaiGrok47
396                | ModelId::MergeGatewayXiaomimimoMimoV26Pro
397                | ModelId::MergeGatewayXiaomimimoMimoV26Flash
398                | ModelId::MergeGatewayMistralLarge4
399                | ModelId::MergeGatewayMetaMuseSparkOpen
400                | ModelId::HuggingFaceMuseSparkOpenBaseten
401        )
402    }
403
404    /// Determine whether the model is a reasoning-capable variant
405    pub fn is_reasoning_variant(&self) -> bool {
406        if let Some(meta) = self.openrouter_metadata() {
407            return meta.reasoning;
408        }
409        self.provider().supports_reasoning(&self.as_str())
410    }
411
412    /// Determine whether the model supports tool calls/function execution
413    pub fn supports_tool_calls(&self) -> bool {
414        if let Some(meta) = self.generated_capabilities() {
415            return meta.tool_call;
416        }
417        if let Some(meta) = self.openrouter_metadata() {
418            return meta.tool_call;
419        }
420        true
421    }
422
423    /// Ordered list of supported input modalities when VT Code has metadata for this model.
424    pub fn input_modalities(&self) -> &'static [&'static str] {
425        self.generated_capabilities().map(|meta| meta.input_modalities).unwrap_or(&[])
426    }
427
428    /// Get the generation/version string for this model
429    pub fn generation(&self) -> &'static str {
430        if let Some(meta) = self.openrouter_metadata() {
431            return meta.generation;
432        }
433        match self {
434            // Gemini generations
435            // OpenAI generations
436            ModelId::GPT62Astra | ModelId::GPT62Sol => "6.2",
437            ModelId::GPT6Astra | ModelId::GPT6Sol | ModelId::GPT6Luna => "6",
438            ModelId::GPT61Sol | ModelId::GPT61Terra => "6.1",
439            ModelId::GPT56Sol | ModelId::GPT56Terra | ModelId::GPT56Luna => "5.6",
440            ModelId::OpenAIGptOss20b | ModelId::OpenAIGptOss120b => "5",
441            // Anthropic generations
442            ModelId::ClaudeSonnet5 => "5",
443            ModelId::ClaudeSonnet55 => "5.5",
444            ModelId::ClaudeHaiku55 => "5.5",
445            ModelId::ClaudeFable5 => "5",
446            ModelId::ClaudeFable51 => "5.1",
447            ModelId::ClaudeFable52 => "5.2",
448            ModelId::ClaudeOpus5 => "5",
449            ModelId::ClaudeOpus55 => "5.5",
450            // DeepSeek generations
451            ModelId::DeepSeekFlash => "4",
452            ModelId::OllamaDeepSeekV41FlashCloud => "4.1",
453            // Mistral generations
454            ModelId::MistralLarge3 => "3",
455            ModelId::MistralLarge4 => "4",
456            ModelId::OllamaMistralLarge4Cloud => "4",
457            ModelId::MergeGatewayDeepseekFlash => "4.1",
458            ModelId::MetaMuseSpark13 | ModelId::MetaMuseSpark13Contributor => "Muse-Spark-1.3",
459            ModelId::MergeGatewayMetaMuseSparkOpen | ModelId::HuggingFaceMuseSparkOpenBaseten => "Muse-Spark-Open",
460            ModelId::OllamaMuseSparkOpenCloud => "Muse-Spark-Open",
461            ModelId::MetaMuseWonder10 => "Muse-Wonder-1.0",
462            ModelId::MetaMuseWonderFull10 => "Muse-Wonder-Full-1.0",
463            ModelId::MetaMuseEmber10 => "Muse-Ember-1.0",
464            // Z.AI generations
465            ModelId::ZaiGlm53
466            | ModelId::ZaiGlm53Flash
467            | ModelId::ZaiGlm53Flashx
468            | ModelId::MergeGatewayZaiGlm53Flash
469            | ModelId::MergeGatewayZaiGlm53Flashx => "5.3",
470            ModelId::OllamaGlm53FlashCloud => "5.3",
471            ModelId::Gemini38Flash => "3.8",
472            ModelId::MergeGatewayGoogleGemini38Flash => "3.8",
473            ModelId::Gemini4Argon => "4",
474            ModelId::Gemini4Carbon => "4",
475            ModelId::Gemini4Hydrogen => "4",
476            ModelId::MergeGatewayGoogleGemini4Argon => "4",
477            ModelId::MergeGatewayGoogleGemini4Carbon => "4",
478            ModelId::MergeGatewayGoogleGemini4Hydrogen => "4",
479            ModelId::OpenCodeGoGlm53 => "5.3",
480            ModelId::OpenCodeGoGpt56Luna => "5.6-luna",
481            ModelId::OpenCodeGoKimiK3 => "k3",
482            ModelId::MiMoV26Pro | ModelId::MiMoV26Flash | ModelId::MiMoV26ProUltraspeed => "v2.6",
483            ModelId::MergeGatewayXiaomimimoMimoV26Pro | ModelId::MergeGatewayXiaomimimoMimoV26Flash => "v2.6",
484            ModelId::MergeGatewayMistralLarge4 => "4",
485            ModelId::OpenCodeGoMinimaxM3 => "m3",
486            ModelId::OllamaGptOss20b => "oss",
487            ModelId::OllamaGptOss20bCloud => "oss-cloud",
488            ModelId::OllamaGptOss120bCloud => "oss-cloud",
489            ModelId::OllamaMinimaxM3Cloud => "minimax-m3",
490            ModelId::OllamaMinimaxM31FlashCloud => "minimax-m3.1",
491            ModelId::OllamaGlm53Cloud => "glm-5.3",
492            ModelId::OllamaGemma4 => "gemma-4",
493            ModelId::LlamaCppGemma426bA4b => "4",
494            ModelId::LlamaCppGemma4E4b => "4",
495            ModelId::LlamaCppGptOss20b => "oss",
496            // MiniMax models
497            ModelId::MinimaxM3 => "M3",
498            ModelId::MinimaxM31Flash | ModelId::MergeGatewayMinimaxM31Flash => "M3.1",
499            // StepFun models
500            ModelId::StepFun37Flash => "3.7",
501            ModelId::StepFun5Preview => "5",
502            // Moonshot models
503            ModelId::MoonshotKimiK31Pro => "k3.1",
504            ModelId::MoonshotKimiK3 => "k3",
505            ModelId::MergeGatewayMoonshotKimiK3 => "k3",
506            ModelId::MergeGatewayMoonshotKimiK31Pro => "k3.1",
507            // Hugging Face generations
508            ModelId::HuggingFaceOpenAIGptOss20b => "oss",
509            ModelId::HuggingFaceOpenAIGptOss120b => "oss",
510            ModelId::HuggingFaceMinimaxM3Novita => "m3",
511            ModelId::HuggingFaceGlm53FlashTogether => "5.3",
512            ModelId::HuggingFaceGlm53Together => "5.3",
513            // xAI models
514            ModelId::XaiGrok46 => "4.6",
515            ModelId::XaiGrok47 => "4.7",
516            ModelId::MergeGatewayXaiGrok46 => "4.6",
517            ModelId::MergeGatewayXaiGrok47 => "4.7",
518            // Qwen models
519            ModelId::MergeGatewayDefaultRouting => "routing",
520            ModelId::MergeGatewayAnthropicClaudeOpus5 => "5",
521            ModelId::MergeGatewayAnthropicClaudeOpus55 => "5.5",
522            ModelId::MergeGatewayAnthropicClaudeSonnet5 => "5",
523            ModelId::MergeGatewayAnthropicClaudeSonnet55 => "5.5",
524            ModelId::MergeGatewayAnthropicClaudeHaiku55 => "5.5",
525            ModelId::MergeGatewayAnthropicClaudeFable51 => "5.1",
526            ModelId::MergeGatewayAnthropicClaudeFable52 => "5.2",
527            ModelId::MergeGatewayAnthropicClaudeHaiku4520251001 => "4.5",
528            ModelId::MergeGatewayMinimaxH3 => "H3",
529            ModelId::MergeGatewayThinkingMachinesInkling => "Inkling",
530            ModelId::MergeGatewayOpenAIGpt56Luna
531            | ModelId::MergeGatewayOpenAIGpt56Sol
532            | ModelId::MergeGatewayOpenAIGpt56Terra => "5.6",
533            ModelId::MergeGatewayOpenAIGpt62Astra | ModelId::MergeGatewayOpenAIGpt62Sol => "6.2",
534            ModelId::MergeGatewayOpenAIGpt6Astra
535            | ModelId::MergeGatewayOpenAIGpt6Sol
536            | ModelId::MergeGatewayOpenAIGpt6Luna => "6",
537            ModelId::MergeGatewayOpenAIGpt61Sol | ModelId::MergeGatewayOpenAIGpt61Terra => "6.1",
538            // Vercel AI Gateway models
539            ModelId::VercelAnthropicClaudeSonnet5 => "5",
540            ModelId::VercelAnthropicClaudeOpus5 => "5",
541            ModelId::VercelAnthropicClaudeOpus55 => "5.5",
542            ModelId::VercelAnthropicClaudeHaiku45 => "4.5",
543            ModelId::VercelOpenAiGpt56Sol | ModelId::VercelOpenAiGpt56Luna => "5.6",
544            ModelId::VercelOpenAiGpt6Sol | ModelId::VercelOpenAiGpt6Luna => "6",
545            ModelId::VercelOpenAiGpt6Astra => "6",
546            ModelId::VercelGoogleGemini38Flash => "3.8",
547            ModelId::VercelDeepseekFlash => "4.1",
548            ModelId::VercelMoonshotaiKimiK3 => "k3",
549            ModelId::VercelMinimaxM3 => "M3",
550            ModelId::VercelSpacexaiGrok47 => "4.7",
551            _ => "unknown",
552        }
553    }
554
555    /// Determine if this model supports GPT-5.1+/5.2+/5.3+ shell tool type
556    pub(crate) fn supports_shell_tool(&self) -> bool {
557        matches!(
558            self,
559            ModelId::GPT62Astra
560                | ModelId::GPT62Sol
561                | ModelId::GPT6Astra
562                | ModelId::GPT6Sol
563                | ModelId::GPT61Sol
564                | ModelId::GPT6Luna
565                | ModelId::GPT56Sol
566                | ModelId::GPT56Terra
567                | ModelId::GPT56Luna
568        )
569    }
570
571    /// Determine if this model supports optimized apply_patch tool
572    pub fn supports_apply_patch_tool(&self) -> bool {
573        false
574    }
575}
576
577#[cfg(test)]
578mod tests {
579    use super::*;
580
581    #[test]
582    fn prefixed_request_model_resolves_on_bare_provider() {
583        // Regression for `openai/gpt-5.6-luna` on provider `openai` resolving
584        // to empty `supported:` and omitting reasoning effort: exact bare hit
585        // and prefixed fallback must agree, while gateway prefixed entries
586        // keep their exact match.
587        let bare = model_catalog_entry("openai", "gpt-5.6-luna").expect("bare openai entry exists");
588        let prefixed = model_catalog_entry("openai", "openai/gpt-5.6-luna").expect("prefixed fallback must resolve");
589        assert_eq!(bare.reasoning_efforts, prefixed.reasoning_efforts);
590        assert!(!prefixed.reasoning_efforts.is_empty());
591
592        let gateway =
593            model_catalog_entry("merge-gateway", "openai/gpt-5.6-luna").expect("gateway prefixed entry exists");
594        assert!(!gateway.reasoning_efforts.is_empty());
595
596        // Asymmetric boundary: unknown model stays missing on both shapes,
597        // and an unrelated prefix must not resolve to the bare model.
598        assert!(model_catalog_entry("openai", "no-such-model-xyz").is_none());
599        assert!(model_catalog_entry("openai", "openai/no-such-model-xyz").is_none());
600        assert!(model_catalog_entry("openai", "other-org/gpt-5.6-luna").is_none());
601    }
602}