2- Use string service tiers in session protocol (#20971)

## Summary
- break service tier session/op/app-server protocol fields from the
closed enum to string tier ids
- send the service tier string directly through model requests, prewarm,
compaction, memories, and TUI/app-server turn starts
- regenerate app-server protocol JSON/TypeScript schemas, removing the
standalone ServiceTier TS enum

## Verification
- just fmt
- cargo check -p codex-core -p codex-app-server -p codex-tui
- just write-app-server-schema

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-05-06 18:00:21 +03:00
committed by GitHub
parent ebd9ec05b4
commit be1d3cff93
65 changed files with 403 additions and 570 deletions

View File

@@ -355,6 +355,23 @@ pub enum ServiceTier {
Flex,
}
impl ServiceTier {
pub const fn request_value(self) -> &'static str {
match self {
Self::Fast => "priority",
Self::Flex => "flex",
}
}
pub fn from_request_value(value: &str) -> Option<Self> {
match value {
"fast" | "priority" => Some(Self::Fast),
"flex" => Some(Self::Flex),
_ => None,
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Display, JsonSchema, TS)]
#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]

View File

@@ -22,7 +22,6 @@ use crate::config_types::CollaborationMode;
use crate::config_types::ModeKind;
use crate::config_types::Personality;
use crate::config_types::ReasoningSummary as ReasoningSummaryConfig;
use crate::config_types::ServiceTier;
use crate::config_types::WindowsSandboxLevel;
use crate::dynamic_tools::DynamicToolCallOutputContentItem;
use crate::dynamic_tools::DynamicToolCallRequest;
@@ -514,7 +513,7 @@ pub enum Op {
/// Use `Some(Some(_))` to set a specific tier, `Some(None)` to clear the
/// preference, or `None` to leave the existing value unchanged.
#[serde(skip_serializing_if = "Option::is_none")]
service_tier: Option<Option<ServiceTier>>,
service_tier: Option<Option<String>>,
/// EXPERIMENTAL - set a pre-set collaboration mode.
/// Takes precedence over model, effort, and developer instructions if set.
@@ -575,7 +574,7 @@ pub enum Op {
/// explicitly clear the tier for this turn, or `None` to keep the existing
/// session preference.
#[serde(default, skip_serializing_if = "Option::is_none")]
service_tier: Option<Option<ServiceTier>>,
service_tier: Option<Option<String>>,
// The JSON schema to use for the final assistant message
final_output_json_schema: Option<Value>,
@@ -652,7 +651,7 @@ pub enum Op {
/// Use `Some(Some(_))` to set a specific tier, `Some(None)` to clear the
/// preference, or `None` to leave the existing value unchanged.
#[serde(skip_serializing_if = "Option::is_none")]
service_tier: Option<Option<ServiceTier>>,
service_tier: Option<Option<String>>,
/// EXPERIMENTAL - set a pre-set collaboration mode.
/// Takes precedence over model, effort, and developer instructions if set.
@@ -3476,7 +3475,7 @@ pub struct SessionConfiguredEvent {
pub model_provider_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub service_tier: Option<ServiceTier>,
pub service_tier: Option<String>,
/// When to escalate for approval for execution
pub approval_policy: AskForApproval,
@@ -3542,7 +3541,7 @@ impl<'de> Deserialize<'de> for SessionConfiguredEvent {
thread_name: Option<String>,
model: String,
model_provider_id: String,
service_tier: Option<ServiceTier>,
service_tier: Option<String>,
approval_policy: AskForApproval,
#[serde(default)]
approvals_reviewer: ApprovalsReviewer,