From f730efcea4c931e6de5b6163ae31a054fdff874c Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Thu, 12 Feb 2026 11:08:56 -0800 Subject: [PATCH] prefix --- codex-rs/core/src/models_manager/manager.rs | 34 +---------- codex-rs/core/tests/suite/remote_models.rs | 63 --------------------- 2 files changed, 1 insertion(+), 96 deletions(-) diff --git a/codex-rs/core/src/models_manager/manager.rs b/codex-rs/core/src/models_manager/manager.rs index 15b3dfe0d0..85d7c034b9 100644 --- a/codex-rs/core/src/models_manager/manager.rs +++ b/codex-rs/core/src/models_manager/manager.rs @@ -137,42 +137,10 @@ impl ModelsManager { // todo(aibrahim): look if we can tighten it to pub(crate) /// Look up model metadata, applying remote overrides and config adjustments. pub async fn get_model_info(&self, model: &str, config: &Config) -> ModelInfo { - let remote = self - .find_remote_model_by_longest_prefix(model, config) - .await; - let model = if let Some(remote) = remote { - ModelInfo { - slug: model.to_string(), - ..remote - } - } else { - model_info::model_info_from_slug(model) - }; + let model = model_info::model_info_from_slug(model); model_info::with_config_overrides(model, config) } - async fn find_remote_model_by_longest_prefix( - &self, - model: &str, - config: &Config, - ) -> Option { - let mut best: Option = None; - for candidate in self.get_remote_models(config).await { - if !model.starts_with(&candidate.slug) { - continue; - } - let is_better_match = if let Some(current) = best.as_ref() { - candidate.slug.len() > current.slug.len() - } else { - true - }; - if is_better_match { - best = Some(candidate); - } - } - best - } - /// Refresh models if the provided ETag differs from the cached ETag. /// /// Uses `Online` strategy to fetch latest models when ETags differ. diff --git a/codex-rs/core/tests/suite/remote_models.rs b/codex-rs/core/tests/suite/remote_models.rs index e20db08617..68a8c01107 100644 --- a/codex-rs/core/tests/suite/remote_models.rs +++ b/codex-rs/core/tests/suite/remote_models.rs @@ -55,69 +55,6 @@ use wiremock::MockServer; const REMOTE_MODEL_SLUG: &str = "codex-test"; -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn remote_models_get_model_info_uses_longest_matching_prefix() -> Result<()> { - skip_if_no_network!(Ok(())); - skip_if_sandbox!(Ok(())); - - let server = MockServer::start().await; - let generic = test_remote_model_with_policy( - "gpt-5.3", - ModelVisibility::List, - 1_000, - TruncationPolicyConfig::bytes(10_000), - ); - let specific = test_remote_model_with_policy( - "gpt-5.3-codex", - ModelVisibility::List, - 1_000, - TruncationPolicyConfig::bytes(10_000), - ); - let specific = ModelInfo { - display_name: "GPT 5.3 Codex".to_string(), - base_instructions: "use specific prefix".to_string(), - ..specific - }; - let generic = ModelInfo { - display_name: "GPT 5.3".to_string(), - base_instructions: "use generic prefix".to_string(), - ..generic - }; - mount_models_once( - &server, - ModelsResponse { - models: vec![generic.clone(), specific.clone()], - }, - ) - .await; - - let codex_home = TempDir::new()?; - let mut config = load_default_config_for_test(&codex_home).await; - config.features.enable(Feature::RemoteModels); - - let auth = CodexAuth::create_dummy_chatgpt_auth_for_testing(); - let provider = ModelProviderInfo { - base_url: Some(format!("{}/v1", server.uri())), - ..built_in_model_providers()["openai"].clone() - }; - let manager = codex_core::test_support::models_manager_with_provider( - codex_home.path().to_path_buf(), - codex_core::test_support::auth_manager_from_auth(auth), - provider, - ); - - manager - .list_models(&config, RefreshStrategy::OnlineIfUncached) - .await; - - let model_info = manager.get_model_info("gpt-5.3-codex-test", &config).await; - - assert_eq!(model_info.slug, "gpt-5.3-codex-test"); - assert_eq!(model_info.base_instructions, specific.base_instructions); - - Ok(()) -} - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn remote_models_long_model_slug_is_sent_with_high_reasoning() -> Result<()> { skip_if_no_network!(Ok(()));