mirror of
https://github.com/openai/codex.git
synced 2026-04-30 09:26:44 +00:00
remove model_family from `config (#7571)
- Remove `model_family` from `config` - Make sure to still override config elements related to `model_family` like supporting reasoning
This commit is contained in:
@@ -16,7 +16,7 @@ use codex_core::auth::AuthCredentialsStoreMode;
|
||||
use codex_core::built_in_model_providers;
|
||||
use codex_core::error::CodexErr;
|
||||
use codex_core::features::Feature;
|
||||
use codex_core::openai_models::model_family::find_family_for_model;
|
||||
use codex_core::openai_models::models_manager::ModelsManager;
|
||||
use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SessionSource;
|
||||
@@ -1017,11 +1017,13 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
|
||||
let config = Arc::new(config);
|
||||
|
||||
let conversation_id = ConversationId::new();
|
||||
|
||||
let auth_mode = AuthMode::ChatGPT;
|
||||
let models_manager = Arc::new(ModelsManager::new(Some(auth_mode)));
|
||||
let model_family = models_manager.construct_model_family(&config.model, &config);
|
||||
let otel_event_manager = OtelEventManager::new(
|
||||
conversation_id,
|
||||
config.model.as_str(),
|
||||
config.model_family.slug.as_str(),
|
||||
model_family.slug.as_str(),
|
||||
None,
|
||||
Some("test@test.com".to_string()),
|
||||
Some(AuthMode::ChatGPT),
|
||||
@@ -1032,6 +1034,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
|
||||
let client = ModelClient::new(
|
||||
Arc::clone(&config),
|
||||
None,
|
||||
model_family,
|
||||
otel_event_manager,
|
||||
provider,
|
||||
effort,
|
||||
@@ -1378,7 +1381,6 @@ async fn context_window_error_sets_total_tokens_to_model_window() -> anyhow::Res
|
||||
let TestCodex { codex, .. } = test_codex()
|
||||
.with_config(|config| {
|
||||
config.model = "gpt-5.1".to_string();
|
||||
config.model_family = find_family_for_model("gpt-5.1");
|
||||
config.model_context_window = Some(272_000);
|
||||
})
|
||||
.build(&server)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use codex_core::features::Feature;
|
||||
use codex_core::openai_models::model_family::find_family_for_model;
|
||||
use codex_core::protocol::AskForApproval;
|
||||
use codex_core::protocol::ENVIRONMENT_CONTEXT_OPEN_TAG;
|
||||
use codex_core::protocol::EventMsg;
|
||||
@@ -73,7 +72,6 @@ async fn codex_mini_latest_tools() -> anyhow::Result<()> {
|
||||
config.user_instructions = Some("be consistent and helpful".to_string());
|
||||
config.features.disable(Feature::ApplyPatchFreeform);
|
||||
config.model = "codex-mini-latest".to_string();
|
||||
config.model_family = find_family_for_model("codex-mini-latest")
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
@@ -125,13 +123,22 @@ async fn prompt_tools_are_consistent_across_requests() -> anyhow::Result<()> {
|
||||
let req1 = mount_sse_once(&server, sse_completed("resp-1")).await;
|
||||
let req2 = mount_sse_once(&server, sse_completed("resp-2")).await;
|
||||
|
||||
let TestCodex { codex, config, .. } = test_codex()
|
||||
let TestCodex {
|
||||
codex,
|
||||
config,
|
||||
conversation_manager,
|
||||
..
|
||||
} = test_codex()
|
||||
.with_config(|config| {
|
||||
config.user_instructions = Some("be consistent and helpful".to_string());
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
let base_instructions = config.model_family.base_instructions.clone();
|
||||
let base_instructions = conversation_manager
|
||||
.get_models_manager()
|
||||
.construct_model_family(&config.model, &config)
|
||||
.base_instructions
|
||||
.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserInput {
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#![allow(clippy::expect_used)]
|
||||
|
||||
use anyhow::Result;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::features::Feature;
|
||||
use codex_core::openai_models::model_family::find_family_for_model;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use core_test_support::assert_regex_match;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
@@ -18,6 +15,7 @@ use core_test_support::responses::start_mock_server;
|
||||
use core_test_support::skip_if_no_network;
|
||||
use core_test_support::test_codex::ApplyPatchModelOutput;
|
||||
use core_test_support::test_codex::ShellModelOutput;
|
||||
use core_test_support::test_codex::TestCodexBuilder;
|
||||
use core_test_support::test_codex::test_codex;
|
||||
use pretty_assertions::assert_eq;
|
||||
use regex_lite::Regex;
|
||||
@@ -41,19 +39,6 @@ const FIXTURE_JSON: &str = r#"{
|
||||
}
|
||||
"#;
|
||||
|
||||
fn configure_shell_command_model(output_type: ShellModelOutput, config: &mut Config) {
|
||||
if !matches!(output_type, ShellModelOutput::ShellCommand) {
|
||||
return;
|
||||
}
|
||||
|
||||
let shell_command_family = find_family_for_model("test-gpt-5-codex");
|
||||
if config.model_family.shell_type == shell_command_family.shell_type {
|
||||
return;
|
||||
}
|
||||
config.model = shell_command_family.slug.clone();
|
||||
config.model_family = shell_command_family;
|
||||
}
|
||||
|
||||
fn shell_responses(
|
||||
call_id: &str,
|
||||
command: Vec<&str>,
|
||||
@@ -113,6 +98,24 @@ fn shell_responses(
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_shell_model(
|
||||
builder: TestCodexBuilder,
|
||||
output_type: ShellModelOutput,
|
||||
include_apply_patch_tool: bool,
|
||||
) -> TestCodexBuilder {
|
||||
let builder = match (output_type, include_apply_patch_tool) {
|
||||
(ShellModelOutput::ShellCommand, _) => builder.with_model("test-gpt-5-codex"),
|
||||
(ShellModelOutput::LocalShell, true) => builder.with_model("gpt-5.1-codex"),
|
||||
(ShellModelOutput::Shell, true) => builder.with_model("gpt-5.1-codex"),
|
||||
(ShellModelOutput::LocalShell, false) => builder.with_model("codex-mini-latest"),
|
||||
(ShellModelOutput::Shell, false) => builder.with_model("gpt-5"),
|
||||
};
|
||||
|
||||
builder.with_config(move |config| {
|
||||
config.include_apply_patch_tool = include_apply_patch_tool;
|
||||
})
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
#[test_case(ShellModelOutput::Shell)]
|
||||
#[test_case(ShellModelOutput::LocalShell)]
|
||||
@@ -122,10 +125,7 @@ async fn shell_output_stays_json_without_freeform_apply_patch(
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex().with_model("gpt-5").with_config(move |config| {
|
||||
config.features.disable(Feature::ApplyPatchFreeform);
|
||||
configure_shell_command_model(output_type, config);
|
||||
});
|
||||
let mut builder = configure_shell_model(test_codex(), output_type, false);
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
let call_id = "shell-json";
|
||||
@@ -177,10 +177,7 @@ async fn shell_output_is_structured_with_freeform_apply_patch(
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex().with_config(move |config| {
|
||||
config.features.enable(Feature::ApplyPatchFreeform);
|
||||
configure_shell_command_model(output_type, config);
|
||||
});
|
||||
let mut builder = configure_shell_model(test_codex(), output_type, true);
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
let call_id = "shell-structured";
|
||||
@@ -225,10 +222,7 @@ async fn shell_output_preserves_fixture_json_without_serialization(
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex().with_model("gpt-5").with_config(move |config| {
|
||||
config.features.disable(Feature::ApplyPatchFreeform);
|
||||
configure_shell_command_model(output_type, config);
|
||||
});
|
||||
let mut builder = configure_shell_model(test_codex(), output_type, false);
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
let fixture_path = test.cwd.path().join("fixture.json");
|
||||
@@ -292,10 +286,7 @@ async fn shell_output_structures_fixture_with_serialization(
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex().with_config(move |config| {
|
||||
config.features.enable(Feature::ApplyPatchFreeform);
|
||||
configure_shell_command_model(output_type, config);
|
||||
});
|
||||
let mut builder = configure_shell_model(test_codex(), output_type, true);
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
let fixture_path = test.cwd.path().join("fixture.json");
|
||||
@@ -354,10 +345,7 @@ async fn shell_output_for_freeform_tool_records_duration(
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex().with_config(move |config| {
|
||||
config.include_apply_patch_tool = true;
|
||||
configure_shell_command_model(output_type, config);
|
||||
});
|
||||
let mut builder = configure_shell_model(test_codex(), output_type, true);
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
let call_id = "shell-structured";
|
||||
@@ -407,11 +395,9 @@ async fn shell_output_reserializes_truncated_content(output_type: ShellModelOutp
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex()
|
||||
.with_model("gpt-5.1-codex")
|
||||
.with_config(move |config| {
|
||||
let mut builder =
|
||||
configure_shell_model(test_codex(), output_type, true).with_config(move |config| {
|
||||
config.tool_output_token_limit = Some(200);
|
||||
configure_shell_command_model(output_type, config);
|
||||
});
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
@@ -712,7 +698,6 @@ async fn shell_output_is_structured_for_nonzero_exit(output_type: ShellModelOutp
|
||||
.with_model("gpt-5.1-codex")
|
||||
.with_config(move |config| {
|
||||
config.include_apply_patch_tool = true;
|
||||
configure_shell_command_model(output_type, config);
|
||||
});
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
@@ -748,7 +733,7 @@ async fn shell_command_output_is_freeform() -> Result<()> {
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let mut builder = test_codex().with_config(move |config| {
|
||||
configure_shell_command_model(ShellModelOutput::ShellCommand, config);
|
||||
config.include_apply_patch_tool = true;
|
||||
});
|
||||
let test = builder.build(&server).await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user