Skip to content

Commit de21997

Browse files
committed
codex: address PR review feedback (#13665)
1 parent b8e4d9a commit de21997

1 file changed

Lines changed: 52 additions & 4 deletions

File tree

codex-rs/core/src/models_manager/manager.rs

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,9 @@ impl ModelsManager {
213213
candidates: &[ModelInfo],
214214
config: &Config,
215215
) -> ModelInfo {
216-
let custom_model = self
217-
.custom_models
218-
.get(model)
219-
.or_else(|| config.custom_model_alias(model));
216+
let custom_model = config
217+
.custom_model_alias(model)
218+
.or_else(|| self.custom_models.get(model));
220219
Self::construct_model_info_from_candidates_with_custom(
221220
model,
222221
candidates,
@@ -1117,6 +1116,55 @@ mod tests {
11171116
assert_eq!(model_info.auto_compact_token_limit, Some(800_000));
11181117
}
11191118

1119+
#[tokio::test]
1120+
async fn get_model_info_prefers_active_config_alias_over_startup_snapshot() {
1121+
let codex_home = tempdir().expect("temp dir");
1122+
let mut config = ConfigBuilder::default()
1123+
.codex_home(codex_home.path().to_path_buf())
1124+
.build()
1125+
.await
1126+
.expect("load default test config");
1127+
1128+
let alias = "gpt-5.4 1m".to_string();
1129+
config.custom_models.insert(
1130+
alias.clone(),
1131+
CustomModelConfig {
1132+
model: "gpt-5.4-updated".to_string(),
1133+
model_context_window: Some(1_000_000),
1134+
model_auto_compact_token_limit: Some(900_000),
1135+
},
1136+
);
1137+
1138+
let auth_manager =
1139+
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
1140+
let manager = ModelsManager::new(
1141+
codex_home.path().to_path_buf(),
1142+
auth_manager,
1143+
Some(ModelsResponse {
1144+
models: vec![
1145+
remote_model("gpt-5.4", "GPT 5.4", 0),
1146+
remote_model("gpt-5.4-updated", "GPT 5.4 Updated", 1),
1147+
],
1148+
}),
1149+
HashMap::from([(
1150+
alias.clone(),
1151+
CustomModelConfig {
1152+
model: "gpt-5.4".to_string(),
1153+
model_context_window: Some(500_000),
1154+
model_auto_compact_token_limit: Some(400_000),
1155+
},
1156+
)]),
1157+
CollaborationModesConfig::default(),
1158+
);
1159+
1160+
let model_info = manager.get_model_info(&alias, &config).await;
1161+
1162+
assert_eq!(model_info.slug, alias);
1163+
assert_eq!(model_info.request_model.as_deref(), Some("gpt-5.4-updated"));
1164+
assert_eq!(model_info.context_window, Some(1_000_000));
1165+
assert_eq!(model_info.auto_compact_token_limit, Some(900_000));
1166+
}
1167+
11201168
#[test]
11211169
fn build_available_models_includes_custom_aliases() {
11221170
let codex_home = tempdir().expect("temp dir");

0 commit comments

Comments
 (0)