mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
## Why Model catalog responses can now advertise a nullable `default_service_tier` for each model. Codex needs to preserve three distinct states all the way from config/app-server inputs to inference: - no explicit service tier, so the client may apply the current model catalog default when FastMode is enabled - explicit `default`, meaning the user intentionally wants standard routing - explicit catalog tier ids such as `priority`, `flex`, or future tiers Keeping those states distinct prevents the UI from showing one tier while core sends another, especially after model switches or app-server `thread/start` / `turn/start` updates. ## What Changed - Plumbed `default_service_tier` through model catalog protocol types, app-server model responses, generated schemas, model cache fixtures, and provider/model-manager conversions. - Added the request-only `default` service tier sentinel and normalized legacy config spelling so `fast` in `config.toml` still materializes as the runtime/request id `priority`. - Moved catalog default resolution to the TUI/client side, including recomputing the effective service tier when model/FastMode-dependent surfaces change. - Updated app-server thread lifecycle config construction so `serviceTier: null` preserves explicit standard-routing intent by mapping to `default` instead of internal `None`. - Kept core responsible for validating explicit tiers against the current model and stripping `default` before `/v1/responses`, without applying catalog defaults itself. ## Validation - `CARGO_INCREMENTAL=0 cargo build -p codex-cli` - `CARGO_INCREMENTAL=0 cargo test -p codex-app-server model_list` - `cargo test -p codex-tui service_tier` - `cargo test -p codex-protocol service_tier_for_request` - `cargo test -p codex-core get_service_tier` - `RUST_MIN_STACK=8388608 CARGO_INCREMENTAL=0 cargo test -p codex-core service_tier`
155 lines
4.7 KiB
Rust
155 lines
4.7 KiB
Rust
use codex_features::Feature;
|
|
use codex_features::Features;
|
|
use codex_protocol::config_types::ModeKind;
|
|
use codex_protocol::openai_models::ConfigShellToolType;
|
|
use codex_protocol::openai_models::ModelInfo;
|
|
use codex_protocol::openai_models::ModelVisibility;
|
|
use codex_protocol::openai_models::TruncationPolicyConfig;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use super::*;
|
|
|
|
fn model_with_shell_type(shell_type: ConfigShellToolType) -> ModelInfo {
|
|
ModelInfo {
|
|
slug: "test-model".to_string(),
|
|
display_name: "Test Model".to_string(),
|
|
description: None,
|
|
default_reasoning_level: None,
|
|
supported_reasoning_levels: Vec::new(),
|
|
shell_type,
|
|
visibility: ModelVisibility::List,
|
|
supported_in_api: true,
|
|
priority: 0,
|
|
additional_speed_tiers: Vec::new(),
|
|
service_tiers: Vec::new(),
|
|
default_service_tier: None,
|
|
availability_nux: None,
|
|
upgrade: None,
|
|
base_instructions: String::new(),
|
|
model_messages: None,
|
|
supports_reasoning_summaries: false,
|
|
default_reasoning_summary: Default::default(),
|
|
support_verbosity: false,
|
|
default_verbosity: None,
|
|
apply_patch_tool_type: None,
|
|
web_search_tool_type: Default::default(),
|
|
truncation_policy: TruncationPolicyConfig::tokens(/*limit*/ 1024),
|
|
supports_parallel_tool_calls: true,
|
|
supports_image_detail_original: false,
|
|
context_window: None,
|
|
max_context_window: None,
|
|
auto_compact_token_limit: None,
|
|
effective_context_window_percent: 95,
|
|
experimental_supported_tools: Vec::new(),
|
|
input_modalities: codex_protocol::openai_models::default_input_modalities(),
|
|
used_fallback_model_metadata: false,
|
|
supports_search_tool: false,
|
|
}
|
|
}
|
|
|
|
fn shell_features() -> Features {
|
|
let mut features = Features::with_defaults();
|
|
features.enable(Feature::ShellTool);
|
|
features.disable(Feature::ShellZshFork);
|
|
features.disable(Feature::UnifiedExec);
|
|
features
|
|
}
|
|
|
|
#[test]
|
|
fn shell_type_is_derived_from_model_and_feature_gates() {
|
|
let model = model_with_shell_type(ConfigShellToolType::UnifiedExec);
|
|
let mut features = shell_features();
|
|
assert_eq!(
|
|
shell_type_for_model_and_features(&model, &features),
|
|
ConfigShellToolType::ShellCommand
|
|
);
|
|
|
|
features.enable(Feature::UnifiedExec);
|
|
let expected_unified_exec = if codex_utils_pty::conpty_supported() {
|
|
ConfigShellToolType::UnifiedExec
|
|
} else {
|
|
ConfigShellToolType::ShellCommand
|
|
};
|
|
assert_eq!(
|
|
shell_type_for_model_and_features(&model, &features),
|
|
expected_unified_exec
|
|
);
|
|
|
|
features.enable(Feature::ShellZshFork);
|
|
assert_eq!(
|
|
shell_type_for_model_and_features(&model, &features),
|
|
ConfigShellToolType::ShellCommand
|
|
);
|
|
|
|
features.disable(Feature::ShellTool);
|
|
assert_eq!(
|
|
shell_type_for_model_and_features(&model, &features),
|
|
ConfigShellToolType::Disabled
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn shell_command_backend_requires_both_shell_tool_and_zsh_fork() {
|
|
let mut features = shell_features();
|
|
assert_eq!(
|
|
shell_command_backend_for_features(&features),
|
|
ShellCommandBackendConfig::Classic
|
|
);
|
|
|
|
features.enable(Feature::ShellZshFork);
|
|
assert_eq!(
|
|
shell_command_backend_for_features(&features),
|
|
ShellCommandBackendConfig::ZshFork
|
|
);
|
|
|
|
features.disable(Feature::ShellTool);
|
|
assert_eq!(
|
|
shell_command_backend_for_features(&features),
|
|
ShellCommandBackendConfig::Classic
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn request_user_input_modes_follow_default_mode_feature() {
|
|
let mut features = Features::with_defaults();
|
|
features.disable(Feature::DefaultModeRequestUserInput);
|
|
assert_eq!(
|
|
request_user_input_available_modes(&features),
|
|
vec![ModeKind::Plan]
|
|
);
|
|
|
|
features.enable(Feature::DefaultModeRequestUserInput);
|
|
assert_eq!(
|
|
request_user_input_available_modes(&features),
|
|
vec![ModeKind::Default, ModeKind::Plan]
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn unified_exec_shell_mode_uses_zsh_fork_only_when_all_inputs_match() {
|
|
let exe = std::env::current_exe().expect("current exe path");
|
|
let shell = exe.clone();
|
|
|
|
let mode = UnifiedExecShellMode::for_session(
|
|
ShellCommandBackendConfig::ZshFork,
|
|
ToolUserShellType::Zsh,
|
|
Some(&shell),
|
|
Some(&exe),
|
|
);
|
|
if cfg!(unix) {
|
|
assert!(matches!(mode, UnifiedExecShellMode::ZshFork(_)));
|
|
} else {
|
|
assert_eq!(mode, UnifiedExecShellMode::Direct);
|
|
}
|
|
|
|
assert_eq!(
|
|
UnifiedExecShellMode::for_session(
|
|
ShellCommandBackendConfig::Classic,
|
|
ToolUserShellType::Zsh,
|
|
Some(&shell),
|
|
Some(&exe),
|
|
),
|
|
UnifiedExecShellMode::Direct
|
|
);
|
|
}
|