mirror of
https://github.com/openai/codex.git
synced 2026-05-01 20:02:05 +03:00
Merge Modelfamily into modelinfo (#8763)
- Merge ModelFamily into ModelInfo - Remove logic for adding instructions to apply patch - Add compaction limit and visible context window to `ModelInfo`
This commit is contained in:
@@ -2,13 +2,13 @@ use crate::client_common::tools::ResponsesApiTool;
|
||||
use crate::client_common::tools::ToolSpec;
|
||||
use crate::features::Feature;
|
||||
use crate::features::Features;
|
||||
use crate::models_manager::model_family::ModelFamily;
|
||||
use crate::tools::handlers::PLAN_TOOL;
|
||||
use crate::tools::handlers::apply_patch::create_apply_patch_freeform_tool;
|
||||
use crate::tools::handlers::apply_patch::create_apply_patch_json_tool;
|
||||
use crate::tools::registry::ToolRegistryBuilder;
|
||||
use codex_protocol::openai_models::ApplyPatchToolType;
|
||||
use codex_protocol::openai_models::ConfigShellToolType;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value as JsonValue;
|
||||
@@ -27,14 +27,14 @@ pub(crate) struct ToolsConfig {
|
||||
}
|
||||
|
||||
pub(crate) struct ToolsConfigParams<'a> {
|
||||
pub(crate) model_family: &'a ModelFamily,
|
||||
pub(crate) model_info: &'a ModelInfo,
|
||||
pub(crate) features: &'a Features,
|
||||
}
|
||||
|
||||
impl ToolsConfig {
|
||||
pub fn new(params: &ToolsConfigParams) -> Self {
|
||||
let ToolsConfigParams {
|
||||
model_family,
|
||||
model_info,
|
||||
features,
|
||||
} = params;
|
||||
let include_apply_patch_tool = features.enabled(Feature::ApplyPatchFreeform);
|
||||
@@ -52,10 +52,10 @@ impl ToolsConfig {
|
||||
ConfigShellToolType::ShellCommand
|
||||
}
|
||||
} else {
|
||||
model_family.shell_type
|
||||
model_info.shell_type
|
||||
};
|
||||
|
||||
let apply_patch_tool_type = match model_family.apply_patch_tool_type {
|
||||
let apply_patch_tool_type = match model_info.apply_patch_tool_type {
|
||||
Some(ApplyPatchToolType::Freeform) => Some(ApplyPatchToolType::Freeform),
|
||||
Some(ApplyPatchToolType::Function) => Some(ApplyPatchToolType::Function),
|
||||
None => {
|
||||
@@ -73,7 +73,7 @@ impl ToolsConfig {
|
||||
web_search_request: include_web_search_request,
|
||||
web_search_cached: include_web_search_cached,
|
||||
include_view_image_tool,
|
||||
experimental_supported_tools: model_family.experimental_supported_tools.clone(),
|
||||
experimental_supported_tools: model_info.experimental_supported_tools.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1232,13 +1232,13 @@ mod tests {
|
||||
#[test]
|
||||
fn test_full_toolset_specs_for_gpt5_codex_unified_exec_web_search() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
features.enable(Feature::ViewImageTool);
|
||||
let config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(&config, None).build();
|
||||
@@ -1294,9 +1294,9 @@ mod tests {
|
||||
|
||||
fn assert_model_tools(model_slug: &str, features: &Features, expected_tools: &[&str]) {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline(model_slug, &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline(model_slug, &config);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features,
|
||||
});
|
||||
let (tools, _) = build_specs(&tools_config, Some(HashMap::new())).build();
|
||||
@@ -1307,12 +1307,12 @@ mod tests {
|
||||
#[test]
|
||||
fn web_search_cached_sets_external_web_access_false() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::WebSearchCached);
|
||||
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(&tools_config, None).build();
|
||||
@@ -1329,13 +1329,13 @@ mod tests {
|
||||
#[test]
|
||||
fn web_search_cached_takes_precedence_over_web_search_request() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::WebSearchCached);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(&tools_config, None).build();
|
||||
@@ -1532,12 +1532,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_build_specs_default_shell_present() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("o3", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("o3", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
features.enable(Feature::UnifiedExec);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(&tools_config, Some(HashMap::new())).build();
|
||||
@@ -1554,12 +1554,12 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_parallel_support_flags() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.disable(Feature::ViewImageTool);
|
||||
features.enable(Feature::UnifiedExec);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(&tools_config, None).build();
|
||||
@@ -1572,14 +1572,13 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_test_model_family_includes_sync_tool() {
|
||||
fn test_test_model_info_includes_sync_tool() {
|
||||
let config = test_config();
|
||||
let model_family =
|
||||
ModelsManager::construct_model_family_offline("test-gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("test-gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.disable(Feature::ViewImageTool);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(&tools_config, None).build();
|
||||
@@ -1605,12 +1604,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_build_specs_mcp_tools_converted() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("o3", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("o3", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(
|
||||
@@ -1700,11 +1699,11 @@ mod tests {
|
||||
#[test]
|
||||
fn test_build_specs_mcp_tools_sorted_by_name() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("o3", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("o3", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
|
||||
@@ -1776,12 +1775,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_mcp_tool_property_missing_type_defaults_to_string() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
|
||||
@@ -1833,12 +1832,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_mcp_tool_integer_normalized_to_number() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
|
||||
@@ -1886,13 +1885,13 @@ mod tests {
|
||||
#[test]
|
||||
fn test_mcp_tool_array_without_items_gets_default_string_items() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
features.enable(Feature::ApplyPatchFreeform);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
|
||||
@@ -1943,12 +1942,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_mcp_tool_anyof_defaults_to_string() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
|
||||
@@ -2055,12 +2054,12 @@ Examples of valid command strings:
|
||||
#[test]
|
||||
fn test_get_openai_tools_mcp_tools_with_additional_properties_schema() {
|
||||
let config = test_config();
|
||||
let model_family = ModelsManager::construct_model_family_offline("gpt-5-codex", &config);
|
||||
let model_info = ModelsManager::construct_model_info_offline("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::UnifiedExec);
|
||||
features.enable(Feature::WebSearchRequest);
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_family: &model_family,
|
||||
model_info: &model_info,
|
||||
features: &features,
|
||||
});
|
||||
let (tools, _) = build_specs(
|
||||
|
||||
Reference in New Issue
Block a user