fix: remove mcp-types from app server protocol (#4537)
We continue the separation between `codex app-server` and `codex
mcp-server`.
In particular, we introduce a new crate, `codex-app-server-protocol`,
and migrate `codex-rs/protocol/src/mcp_protocol.rs` into it, renaming it
`codex-rs/app-server-protocol/src/protocol.rs`.
Because `ConversationId` was defined in `mcp_protocol.rs`, we move it
into its own file, `codex-rs/protocol/src/conversation_id.rs`, and
because it is referenced in a ton of places, we have to touch a lot of
files as part of this PR.
We also decide to get away from proper JSON-RPC 2.0 semantics, so we
also introduce `codex-rs/app-server-protocol/src/jsonrpc_lite.rs`, which
is basically the same `JSONRPCMessage` type defined in `mcp-types`
except with all of the `"jsonrpc": "2.0"` removed.
Getting rid of `"jsonrpc": "2.0"` makes our serialization logic
considerably simpler, as we can lean heavier on serde to serialize
directly into the wire format that we use now.
2025-09-30 19:16:26 -07:00
|
|
|
use codex_app_server_protocol::AuthMode;
|
2025-08-19 10:55:07 -07:00
|
|
|
use codex_core::protocol_config_types::ReasoningEffort;
|
|
|
|
|
|
2025-10-21 11:15:17 -07:00
|
|
|
/// A reasoning effort option that can be surfaced for a model.
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
pub struct ReasoningEffortPreset {
|
|
|
|
|
/// Effort level that the model supports.
|
|
|
|
|
pub effort: ReasoningEffort,
|
|
|
|
|
/// Short human description shown next to the effort in UIs.
|
|
|
|
|
pub description: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Metadata describing a Codex-supported model.
|
2025-08-19 10:55:07 -07:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
pub struct ModelPreset {
|
|
|
|
|
/// Stable identifier for the preset.
|
|
|
|
|
pub id: &'static str,
|
|
|
|
|
/// Model slug (e.g., "gpt-5").
|
|
|
|
|
pub model: &'static str,
|
2025-10-21 11:15:17 -07:00
|
|
|
/// Display name shown in UIs.
|
|
|
|
|
pub display_name: &'static str,
|
|
|
|
|
/// Short human description shown in UIs.
|
|
|
|
|
pub description: &'static str,
|
|
|
|
|
/// Reasoning effort applied when none is explicitly chosen.
|
|
|
|
|
pub default_reasoning_effort: ReasoningEffort,
|
|
|
|
|
/// Supported reasoning effort options.
|
|
|
|
|
pub supported_reasoning_efforts: &'static [ReasoningEffortPreset],
|
|
|
|
|
/// Whether this is the default model for new users.
|
|
|
|
|
pub is_default: bool,
|
2025-08-19 10:55:07 -07:00
|
|
|
}
|
|
|
|
|
|
2025-09-14 21:32:18 -04:00
|
|
|
const PRESETS: &[ModelPreset] = &[
|
|
|
|
|
ModelPreset {
|
2025-10-21 11:15:17 -07:00
|
|
|
id: "gpt-5-codex",
|
2025-09-15 08:17:13 -07:00
|
|
|
model: "gpt-5-codex",
|
2025-10-21 11:15:17 -07:00
|
|
|
display_name: "gpt-5-codex",
|
|
|
|
|
description: "Optimized for coding tasks with many tools.",
|
|
|
|
|
default_reasoning_effort: ReasoningEffort::Medium,
|
|
|
|
|
supported_reasoning_efforts: &[
|
|
|
|
|
ReasoningEffortPreset {
|
|
|
|
|
effort: ReasoningEffort::Low,
|
|
|
|
|
description: "Fastest responses with limited reasoning",
|
|
|
|
|
},
|
|
|
|
|
ReasoningEffortPreset {
|
|
|
|
|
effort: ReasoningEffort::Medium,
|
|
|
|
|
description: "Dynamically adjusts reasoning based on the task",
|
|
|
|
|
},
|
|
|
|
|
ReasoningEffortPreset {
|
|
|
|
|
effort: ReasoningEffort::High,
|
|
|
|
|
description: "Maximizes reasoning depth for complex or ambiguous problems",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
is_default: true,
|
2025-09-14 21:32:18 -04:00
|
|
|
},
|
|
|
|
|
ModelPreset {
|
2025-10-21 11:15:17 -07:00
|
|
|
id: "gpt-5",
|
2025-09-14 21:32:18 -04:00
|
|
|
model: "gpt-5",
|
2025-10-21 11:15:17 -07:00
|
|
|
display_name: "gpt-5",
|
|
|
|
|
description: "Broad world knowledge with strong general reasoning.",
|
|
|
|
|
default_reasoning_effort: ReasoningEffort::Medium,
|
|
|
|
|
supported_reasoning_efforts: &[
|
|
|
|
|
ReasoningEffortPreset {
|
|
|
|
|
effort: ReasoningEffort::Minimal,
|
|
|
|
|
description: "Fastest responses with little reasoning",
|
|
|
|
|
},
|
|
|
|
|
ReasoningEffortPreset {
|
|
|
|
|
effort: ReasoningEffort::Low,
|
|
|
|
|
description: "Balances speed with some reasoning; useful for straightforward queries and short explanations",
|
|
|
|
|
},
|
|
|
|
|
ReasoningEffortPreset {
|
|
|
|
|
effort: ReasoningEffort::Medium,
|
|
|
|
|
description: "Provides a solid balance of reasoning depth and latency for general-purpose tasks",
|
|
|
|
|
},
|
|
|
|
|
ReasoningEffortPreset {
|
|
|
|
|
effort: ReasoningEffort::High,
|
|
|
|
|
description: "Maximizes reasoning depth for complex or ambiguous problems",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
is_default: false,
|
2025-09-14 21:32:18 -04:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2025-09-22 20:10:52 -07:00
|
|
|
pub fn builtin_model_presets(_auth_mode: Option<AuthMode>) -> Vec<ModelPreset> {
|
|
|
|
|
PRESETS.to_vec()
|
2025-08-19 10:55:07 -07:00
|
|
|
}
|
2025-10-21 11:15:17 -07:00
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn only_one_default_model_is_configured() {
|
|
|
|
|
let default_models = PRESETS.iter().filter(|preset| preset.is_default).count();
|
|
|
|
|
assert!(default_models == 1);
|
|
|
|
|
}
|
|
|
|
|
}
|