codex: fix CI failure on PR #13187

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Dylan Hurd
2026-03-06 23:02:26 -08:00
parent 66cad6a734
commit 17db82635d
5 changed files with 82 additions and 7 deletions

View File

@@ -302,6 +302,7 @@ use codex_async_utils::OrCancelExt;
use codex_otel::SessionTelemetry;
use codex_otel::TelemetryAuthMode;
use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::CollaborationModeMask;
use codex_protocol::config_types::Personality;
use codex_protocol::config_types::ReasoningSummary as ReasoningSummaryConfig;
use codex_protocol::config_types::ServiceTier;
@@ -973,6 +974,26 @@ impl SessionConfiguration {
}
}
fn merge_collaboration_mode_with_preset(
collaboration_mode: CollaborationMode,
preset: &CollaborationModeMask,
) -> CollaborationMode {
CollaborationMode {
mode: collaboration_mode.mode,
settings: Settings {
model: collaboration_mode.settings.model,
reasoning_effort: collaboration_mode
.settings
.reasoning_effort
.or(preset.reasoning_effort.flatten()),
developer_instructions: collaboration_mode
.settings
.developer_instructions
.or_else(|| preset.developer_instructions.clone().flatten()),
},
}
}
#[derive(Default, Clone)]
pub(crate) struct SessionSettingsUpdate {
pub(crate) cwd: Option<PathBuf>,
@@ -988,6 +1009,23 @@ pub(crate) struct SessionSettingsUpdate {
}
impl Session {
fn resolve_session_settings_update(
&self,
mut updates: SessionSettingsUpdate,
) -> SessionSettingsUpdate {
updates.collaboration_mode = updates.collaboration_mode.map(|collaboration_mode| {
self.services
.models_manager
.list_collaboration_modes()
.into_iter()
.find(|preset| preset.mode == Some(collaboration_mode.mode))
.map_or(collaboration_mode.clone(), |preset| {
merge_collaboration_mode_with_preset(collaboration_mode, &preset)
})
});
updates
}
/// Builds the `x-codex-beta-features` header value for this session.
///
/// `ModelClient` is session-scoped and intentionally does not depend on the full `Config`, so
@@ -2081,6 +2119,7 @@ impl Session {
&self,
updates: SessionSettingsUpdate,
) -> ConstraintResult<()> {
let updates = self.resolve_session_settings_update(updates);
let mut state = self.state.lock().await;
match state.session_configuration.apply(&updates) {
@@ -2113,6 +2152,7 @@ impl Session {
sub_id: String,
updates: SessionSettingsUpdate,
) -> ConstraintResult<Arc<TurnContext>> {
let updates = self.resolve_session_settings_update(updates);
let (
session_configuration,
sandbox_policy_changed,

View File

@@ -386,6 +386,20 @@ impl ModelsManager {
codex_home: PathBuf,
auth_manager: Arc<AuthManager>,
provider: ModelProviderInfo,
) -> Self {
Self::with_provider_and_plan_instructions_for_tests(
codex_home,
auth_manager,
provider,
None,
)
}
pub(crate) fn with_provider_and_plan_instructions_for_tests(
codex_home: PathBuf,
auth_manager: Arc<AuthManager>,
provider: ModelProviderInfo,
plan_mode_developer_instructions: Option<String>,
) -> Self {
let cache_path = codex_home.join(MODEL_CACHE_FILE);
let cache_manager = ModelsCacheManager::new(cache_path, DEFAULT_MODEL_CACHE_TTL);
@@ -400,7 +414,7 @@ impl ModelsManager {
etag: RwLock::new(None),
cache_manager,
provider,
plan_mode_developer_instructions: None,
plan_mode_developer_instructions,
}
}

View File

@@ -60,8 +60,14 @@ pub fn thread_manager_with_models_provider_and_home(
auth: CodexAuth,
provider: ModelProviderInfo,
codex_home: PathBuf,
plan_mode_developer_instructions: Option<String>,
) -> ThreadManager {
ThreadManager::with_models_provider_and_home_for_tests(auth, provider, codex_home)
ThreadManager::with_models_provider_and_home_and_plan_instructions_for_tests(
auth,
provider,
codex_home,
plan_mode_developer_instructions,
)
}
pub fn models_manager_with_provider(

View File

@@ -209,6 +209,17 @@ impl ThreadManager {
auth: CodexAuth,
provider: ModelProviderInfo,
codex_home: PathBuf,
) -> Self {
Self::with_models_provider_and_home_and_plan_instructions_for_tests(
auth, provider, codex_home, None,
)
}
pub(crate) fn with_models_provider_and_home_and_plan_instructions_for_tests(
auth: CodexAuth,
provider: ModelProviderInfo,
codex_home: PathBuf,
plan_mode_developer_instructions: Option<String>,
) -> Self {
set_thread_manager_test_mode_for_tests(true);
let auth_manager = AuthManager::from_auth_for_testing(auth);
@@ -224,11 +235,14 @@ impl ThreadManager {
state: Arc::new(ThreadManagerState {
threads: Arc::new(RwLock::new(HashMap::new())),
thread_created_tx,
models_manager: Arc::new(ModelsManager::with_provider_for_tests(
codex_home,
auth_manager.clone(),
provider,
)),
models_manager: Arc::new(
ModelsManager::with_provider_and_plan_instructions_for_tests(
codex_home,
auth_manager.clone(),
provider,
plan_mode_developer_instructions,
),
),
skills_manager,
plugins_manager,
mcp_manager,

View File

@@ -193,6 +193,7 @@ impl TestCodexBuilder {
auth.clone(),
config.model_provider.clone(),
config.codex_home.clone(),
config.plan_mode_developer_instructions.clone(),
)
};
let thread_manager = Arc::new(thread_manager);