mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Remove retired model entries while preserving migration prompts (#44250)
## Why Saved model selections can outlive their bundled catalog entries and still need migration guidance. ## What changed - Remove `gpt-5.2` and `gpt-5.4-mini` from the bundled model catalog. - Preserve migration from saved `gpt-5.4-mini` selections to `gpt-5.6-luna` when the old model is absent, while respecting catalog-provided migration metadata. - Update tests and snapshots to use current models or explicit test fixtures, and remove the obsolete prompt fixture. ## Testing Extend migration tests to cover catalog metadata precedence, saved selections, replacement model and reasoning-effort persistence, acknowledged prompts, and missing or hidden migration targets. GitOrigin-RevId: 82beea504cc4a15699677c28a61ec0939af3069c
This commit is contained in:
@@ -57,8 +57,8 @@ fn activation_models() -> Vec<ModelInfo> {
|
||||
.expect("bundled models")
|
||||
.models
|
||||
.into_iter()
|
||||
.find(|model| model.slug == "gpt-5.4")
|
||||
.expect("bundled gpt-5.4");
|
||||
.find(|model| model.slug == "gpt-5.5")
|
||||
.expect("bundled gpt-5.5");
|
||||
[MODEL_A, MODEL_B]
|
||||
.into_iter()
|
||||
.map(|slug| ModelInfo {
|
||||
|
||||
@@ -9,7 +9,6 @@ use crate::agents_md_manager::AgentsMdManager;
|
||||
use crate::compact::InitialContextInjection;
|
||||
use crate::config::ConfigBuilder;
|
||||
use crate::config::ConfigOverrides;
|
||||
use crate::config::test_config;
|
||||
use crate::context::ContextualUserFragment;
|
||||
use crate::context::DeveloperInstructions;
|
||||
use crate::context::GuardianContextMode;
|
||||
@@ -54,7 +53,6 @@ use codex_login::auth::AgentIdentityAuthPolicy;
|
||||
use codex_model_provider::create_model_provider;
|
||||
use codex_model_provider_info::ModelProviderInfo;
|
||||
use codex_model_provider_info::built_in_model_providers;
|
||||
use codex_models_manager::bundled_models_response;
|
||||
use codex_models_manager::model_info;
|
||||
use codex_models_manager::test_support::construct_model_info_offline_for_tests;
|
||||
use codex_models_manager::test_support::get_model_offline_for_tests;
|
||||
@@ -294,11 +292,6 @@ impl StepContext {
|
||||
|
||||
mod guardian_tests;
|
||||
|
||||
struct InstructionsTestCase {
|
||||
slug: &'static str,
|
||||
expects_apply_patch_description: bool,
|
||||
}
|
||||
|
||||
fn user_message(text: &str) -> ResponseItem {
|
||||
ResponseItem::Message {
|
||||
id: None,
|
||||
@@ -1616,67 +1609,6 @@ async fn user_shell_commands_remain_login_shells_when_model_login_shells_are_dis
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_base_instructions_no_user_content() {
|
||||
let prompt_path = codex_utils_cargo_bin::find_resource!(
|
||||
"tests/fixtures/prompt_with_apply_patch_instructions.md"
|
||||
)
|
||||
.expect("resolve prompt fixture path");
|
||||
let prompt_with_apply_patch_instructions =
|
||||
std::fs::read_to_string(prompt_path).expect("read prompt fixture");
|
||||
let models_response = bundled_models_response()
|
||||
.unwrap_or_else(|err| panic!("bundled models.json should parse: {err}"));
|
||||
let model_info_for_slug = |slug: &str, config: &Config| {
|
||||
let model = models_response
|
||||
.models
|
||||
.iter()
|
||||
.find(|candidate| candidate.slug == slug)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| panic!("model slug {slug} is missing from models.json"));
|
||||
model_info::with_config_overrides(model, &config.to_models_manager_config())
|
||||
};
|
||||
let test_cases = vec![
|
||||
InstructionsTestCase {
|
||||
slug: "gpt-5.4",
|
||||
expects_apply_patch_description: false,
|
||||
},
|
||||
InstructionsTestCase {
|
||||
slug: "gpt-5.4-mini",
|
||||
expects_apply_patch_description: false,
|
||||
},
|
||||
InstructionsTestCase {
|
||||
slug: "gpt-5.5",
|
||||
expects_apply_patch_description: false,
|
||||
},
|
||||
InstructionsTestCase {
|
||||
slug: "gpt-5.2",
|
||||
expects_apply_patch_description: false,
|
||||
},
|
||||
];
|
||||
|
||||
let (session, _turn_context) = make_session_and_context().await;
|
||||
let config = test_config().await;
|
||||
|
||||
for test_case in test_cases {
|
||||
let model_info = model_info_for_slug(test_case.slug, &config);
|
||||
let model_instructions = model_info.get_model_instructions(config.personality);
|
||||
if test_case.expects_apply_patch_description {
|
||||
assert_eq!(
|
||||
model_instructions.as_str(),
|
||||
prompt_with_apply_patch_instructions
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
let mut state = session.state.lock().await;
|
||||
state.session_configuration.base_instructions = model_instructions.clone();
|
||||
}
|
||||
|
||||
let base_instructions = session.get_base_instructions().await;
|
||||
assert_eq!(base_instructions.text, model_instructions);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn reload_user_config_layer_updates_effective_apps_config() {
|
||||
let (session, _turn_context) = make_session_and_context().await;
|
||||
@@ -4876,13 +4808,13 @@ async fn turn_context_with_model_updates_model_fields() {
|
||||
));
|
||||
turn_context.current_settings.store(Arc::clone(¤t));
|
||||
let updated = turn_context
|
||||
.with_model("gpt-5.4".to_string(), &session.services.models_manager)
|
||||
.with_model("gpt-5.5".to_string(), &session.services.models_manager)
|
||||
.await;
|
||||
let expected_model_info = session
|
||||
.services
|
||||
.models_manager
|
||||
.get_model_info(
|
||||
"gpt-5.4",
|
||||
"gpt-5.5",
|
||||
&updated.config.as_ref().to_models_manager_config(),
|
||||
)
|
||||
.await;
|
||||
@@ -4923,8 +4855,8 @@ async fn turn_context_with_model_updates_model_fields() {
|
||||
&updated.current_settings.load_full(),
|
||||
&turn_context.current_settings.load_full()
|
||||
));
|
||||
assert_eq!(updated.config.model.as_deref(), Some("gpt-5.4"));
|
||||
assert_eq!(updated.collaboration_mode().model(), "gpt-5.4");
|
||||
assert_eq!(updated.config.model.as_deref(), Some("gpt-5.5"));
|
||||
assert_eq!(updated.collaboration_mode().model(), "gpt-5.5");
|
||||
assert_eq!(updated.model_info().as_ref(), &expected_model_info);
|
||||
assert_eq!(
|
||||
updated.reasoning_effort(),
|
||||
|
||||
@@ -30,6 +30,7 @@ use codex_login::AuthManager;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_model_provider::create_model_provider;
|
||||
use codex_model_provider_info::built_in_model_providers;
|
||||
use codex_models_manager::manager::StaticModelsManager;
|
||||
use codex_protocol::AgentPath;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::config_types::ApprovalsReviewer;
|
||||
@@ -406,11 +407,28 @@ async fn multi_agent_v2_spawn_fork_turns_all_applies_agent_type_override() {
|
||||
.expect("fork_turns=all should apply agent_type overrides");
|
||||
}
|
||||
|
||||
fn service_tier_test_catalog() -> codex_protocol::openai_models::ModelsResponse {
|
||||
let mut catalog = codex_models_manager::bundled_models_response().expect("bundled models");
|
||||
let mut model = catalog
|
||||
.models
|
||||
.iter()
|
||||
.find(|model| model.slug == "gpt-5.5")
|
||||
.expect("current model")
|
||||
.clone();
|
||||
model.slug = "test-model-without-fast".to_string();
|
||||
model.service_tiers.clear();
|
||||
model.additional_speed_tiers.clear();
|
||||
model.default_service_tier = None;
|
||||
catalog.models.push(model);
|
||||
catalog
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn spawn_agent_service_tier_uses_root_preference_when_root_model_cannot_support_it() {
|
||||
let (_session, turn) = make_session_and_context().await;
|
||||
let mut config = (*turn.config).clone();
|
||||
config.model = Some("gpt-5.4-mini".to_string());
|
||||
config.model = Some("test-model-without-fast".to_string());
|
||||
config.model_catalog = Some(service_tier_test_catalog());
|
||||
config.service_tier = Some(ServiceTier::Fast.request_value().to_string());
|
||||
let manager = thread_manager();
|
||||
let root = manager
|
||||
@@ -419,7 +437,7 @@ async fn spawn_agent_service_tier_uses_root_preference_when_root_model_cannot_su
|
||||
.expect("root thread should start");
|
||||
assert_eq!(root.thread.config_snapshot().await.service_tier, None);
|
||||
|
||||
config.model = Some("gpt-5.4".to_string());
|
||||
config.model = Some("gpt-5.5".to_string());
|
||||
apply_spawn_agent_service_tier(root.thread.session.as_ref(), &mut config)
|
||||
.await
|
||||
.expect("root preference should be resolved against the child model");
|
||||
@@ -440,9 +458,10 @@ async fn spawn_agent_service_tier_inheritance_uses_root_preference_and_child_mod
|
||||
{
|
||||
let (mut session, turn) = make_session_and_context().await;
|
||||
let mut turn = turn
|
||||
.with_model("gpt-5.4".to_string(), &session.services.models_manager)
|
||||
.with_model("gpt-5.5".to_string(), &session.services.models_manager)
|
||||
.await;
|
||||
let mut config = (*turn.config).clone();
|
||||
config.model_catalog = Some(service_tier_test_catalog());
|
||||
config.service_tier = Some(ServiceTier::Fast.request_value().to_string());
|
||||
turn.config = Arc::new(config);
|
||||
let manager = thread_manager();
|
||||
@@ -451,6 +470,10 @@ async fn spawn_agent_service_tier_inheritance_uses_root_preference_and_child_mod
|
||||
.await
|
||||
.expect("root thread should start");
|
||||
session.services.agent_control = root.thread.session.services.agent_control.clone();
|
||||
session.services.models_manager = Arc::new(StaticModelsManager::new(
|
||||
/*auth_manager*/ None,
|
||||
service_tier_test_catalog(),
|
||||
));
|
||||
session.thread_id = root.thread_id;
|
||||
|
||||
let output = SpawnAgentHandler::default()
|
||||
@@ -481,9 +504,10 @@ async fn spawn_agent_service_tier_inheritance_uses_root_preference_and_child_mod
|
||||
{
|
||||
let (mut session, turn) = make_session_and_context().await;
|
||||
let mut turn = turn
|
||||
.with_model("gpt-5.4".to_string(), &session.services.models_manager)
|
||||
.with_model("gpt-5.5".to_string(), &session.services.models_manager)
|
||||
.await;
|
||||
let mut config = (*turn.config).clone();
|
||||
config.model_catalog = Some(service_tier_test_catalog());
|
||||
config.service_tier = Some(ServiceTier::Fast.request_value().to_string());
|
||||
turn.config = Arc::new(config);
|
||||
let manager = thread_manager();
|
||||
@@ -492,6 +516,10 @@ async fn spawn_agent_service_tier_inheritance_uses_root_preference_and_child_mod
|
||||
.await
|
||||
.expect("root thread should start");
|
||||
session.services.agent_control = root.thread.session.services.agent_control.clone();
|
||||
session.services.models_manager = Arc::new(StaticModelsManager::new(
|
||||
/*auth_manager*/ None,
|
||||
service_tier_test_catalog(),
|
||||
));
|
||||
session.thread_id = root.thread_id;
|
||||
|
||||
let output = SpawnAgentHandler::default()
|
||||
@@ -501,7 +529,7 @@ async fn spawn_agent_service_tier_inheritance_uses_root_preference_and_child_mod
|
||||
"spawn_agent",
|
||||
function_payload(json!({
|
||||
"message": "inspect this repo",
|
||||
"model": "gpt-5.4-mini"
|
||||
"model": "test-model-without-fast"
|
||||
})),
|
||||
))
|
||||
.await
|
||||
@@ -531,7 +559,7 @@ async fn spawn_agent_service_tier_inheritance_uses_root_preference_and_child_mod
|
||||
.join("service-tier-role.toml");
|
||||
tokio::fs::write(
|
||||
&role_config_path,
|
||||
r#"model = "gpt-5.4"
|
||||
r#"model = "gpt-5.5"
|
||||
service_tier = "priority"
|
||||
"#,
|
||||
)
|
||||
@@ -592,7 +620,7 @@ async fn spawn_agent_role_service_tier_cannot_override_root_preference() {
|
||||
|
||||
let (mut session, turn) = make_session_and_context().await;
|
||||
let mut turn = turn
|
||||
.with_model("gpt-5.4".to_string(), &session.services.models_manager)
|
||||
.with_model("gpt-5.5".to_string(), &session.services.models_manager)
|
||||
.await;
|
||||
tokio::fs::create_dir_all(&turn.config.codex_home)
|
||||
.await
|
||||
@@ -600,7 +628,7 @@ async fn spawn_agent_role_service_tier_cannot_override_root_preference() {
|
||||
let role_config_path = turn.config.codex_home.as_path().join("tiered-role.toml");
|
||||
tokio::fs::write(
|
||||
&role_config_path,
|
||||
r#"model = "gpt-5.4"
|
||||
r#"model = "gpt-5.5"
|
||||
service_tier = "turbo"
|
||||
"#,
|
||||
)
|
||||
@@ -664,7 +692,7 @@ async fn spawn_agent_full_history_fork_inherits_root_service_tier() {
|
||||
|
||||
let (mut session, turn) = make_session_and_context().await;
|
||||
let mut turn = turn
|
||||
.with_model("gpt-5.4".to_string(), &session.services.models_manager)
|
||||
.with_model("gpt-5.5".to_string(), &session.services.models_manager)
|
||||
.await;
|
||||
let mut config = (*turn.config).clone();
|
||||
config.service_tier = Some(ServiceTier::Fast.request_value().to_string());
|
||||
@@ -714,7 +742,7 @@ async fn multi_agent_v2_full_history_fork_inherits_root_service_tier() {
|
||||
|
||||
let (mut session, turn) = make_session_and_context().await;
|
||||
let mut turn = turn
|
||||
.with_model("gpt-5.4".to_string(), &session.services.models_manager)
|
||||
.with_model("gpt-5.5".to_string(), &session.services.models_manager)
|
||||
.await;
|
||||
let mut config = (*turn.config).clone();
|
||||
config.service_tier = Some(ServiceTier::Fast.request_value().to_string());
|
||||
|
||||
Reference in New Issue
Block a user