From bdea9974d9f41bc295defc1b7c4c0b4739913444 Mon Sep 17 00:00:00 2001 From: sayan-oai Date: Sun, 15 Feb 2026 21:18:35 -0800 Subject: [PATCH] fix: only emit unknown model warning on user turns (#11884) ###### Context unknown model warning added in #11690 has [issues](https://github.com/openai/codex/actions/runs/22047424710/job/63700733887) on ubuntu runners because we potentially emit it on all new turns, including ones with intentionally fake models (i.e., `mock-model` in a test). ###### Fix change the warning to only emit on user turns/review turns. ###### Tests CI now passes on ubuntu, still passes locally --- codex-rs/core/src/codex.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 437fd9e80..502d30748 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1846,11 +1846,13 @@ impl Session { } } - let resolved_model_slug = session_configuration.collaboration_mode.model().to_string(); let model_info = self .services .models_manager - .get_model_info(resolved_model_slug.as_str(), &per_turn_config) + .get_model_info( + session_configuration.collaboration_mode.model(), + &per_turn_config, + ) .await; let mut turn_context: TurnContext = Self::make_turn_context( Some(Arc::clone(&self.services.auth_manager)), @@ -1858,7 +1860,7 @@ impl Session { session_configuration.provider.clone(), &session_configuration, per_turn_config, - model_info.clone(), + model_info, self.services .network_proxy .as_ref() @@ -1871,19 +1873,23 @@ impl Session { turn_context.final_output_json_schema = final_schema; } let turn_context = Arc::new(turn_context); - if model_info.used_fallback_model_metadata { + turn_context.turn_metadata_state.spawn_git_enrichment_task(); + turn_context + } + + pub(crate) async fn maybe_emit_unknown_model_warning_for_turn(&self, tc: &TurnContext) { + if tc.model_info.used_fallback_model_metadata { self.send_event( - turn_context.as_ref(), + tc, EventMsg::Warning(WarningEvent { message: format!( - "Model metadata for `{resolved_model_slug}` not found. Defaulting to fallback metadata; this can degrade performance and cause issues." + "Model metadata for `{}` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.", + tc.model_info.slug ), }), ) .await; } - turn_context.turn_metadata_state.spawn_git_enrichment_task(); - turn_context } pub(crate) async fn new_default_turn(&self) -> Arc { @@ -3454,6 +3460,8 @@ mod handlers { // new_turn_with_sub_id already emits the error event. return; }; + sess.maybe_emit_unknown_model_warning_for_turn(current_context.as_ref()) + .await; current_context.otel_manager.user_prompt(&items); // Attempt to inject input into current task. @@ -4058,6 +4066,8 @@ mod handlers { review_request: ReviewRequest, ) { let turn_context = sess.new_default_turn_with_sub_id(sub_id.clone()).await; + sess.maybe_emit_unknown_model_warning_for_turn(turn_context.as_ref()) + .await; sess.refresh_mcp_servers_if_requested(&turn_context).await; match resolve_review_request(review_request, turn_context.cwd.as_path()) { Ok(resolved) => {