Wire with_remote_overrides to construct model families (#7621)

- This PR wires `with_remote_overrides` and make the
`construct_model_families` an async function
- Moves getting model family a level above to keep the function `sync`
- Updates the tests to local, offline, and `sync` helper for model
families
This commit is contained in:
Ahmed Ibrahim
2025-12-05 10:40:15 -08:00
committed by GitHub
parent 5f80ad6da8
commit d08efb1743
16 changed files with 147 additions and 108 deletions

View File

@@ -11,6 +11,7 @@ use codex_core::config::Config;
use codex_core::config::types::Notifications;
use codex_core::git_info::current_branch_name;
use codex_core::git_info::local_git_branches;
use codex_core::openai_models::model_family::ModelFamily;
use codex_core::openai_models::models_manager::ModelsManager;
use codex_core::project_doc::DEFAULT_PROJECT_DOC_FILENAME;
use codex_core::protocol::AgentMessageDeltaEvent;
@@ -261,6 +262,7 @@ pub(crate) struct ChatWidgetInit {
pub(crate) feedback: codex_feedback::CodexFeedback,
pub(crate) skills: Option<Vec<SkillMetadata>>,
pub(crate) is_first_run: bool,
pub(crate) model_family: ModelFamily,
}
#[derive(Default)]
@@ -277,6 +279,7 @@ pub(crate) struct ChatWidget {
bottom_pane: BottomPane,
active_cell: Option<Box<dyn HistoryCell>>,
config: Config,
model_family: ModelFamily,
auth_manager: Arc<AuthManager>,
models_manager: Arc<ModelsManager>,
session_header: SessionHeader,
@@ -465,15 +468,13 @@ impl ChatWidget {
}
fn on_agent_reasoning_final(&mut self) {
let reasoning_summary_format = self.get_model_family().reasoning_summary_format;
// At the end of a reasoning block, record transcript-only content.
self.full_reasoning_buffer.push_str(&self.reasoning_buffer);
let model_family = self
.models_manager
.construct_model_family(&self.config.model, &self.config);
if !self.full_reasoning_buffer.is_empty() {
let cell = history_cell::new_reasoning_summary_block(
self.full_reasoning_buffer.clone(),
&model_family,
reasoning_summary_format,
);
self.add_boxed_history(cell);
}
@@ -647,6 +648,9 @@ impl ChatWidget {
self.stream_controller = None;
self.maybe_show_pending_rate_limit_prompt();
}
pub(crate) fn get_model_family(&self) -> ModelFamily {
self.model_family.clone()
}
fn on_error(&mut self, message: String) {
self.finalize_turn();
@@ -1249,6 +1253,7 @@ impl ChatWidget {
feedback,
skills,
is_first_run,
model_family,
} = common;
let mut rng = rand::rng();
let placeholder = EXAMPLE_PROMPTS[rng.random_range(0..EXAMPLE_PROMPTS.len())].to_string();
@@ -1270,6 +1275,7 @@ impl ChatWidget {
}),
active_cell: None,
config: config.clone(),
model_family,
auth_manager,
models_manager,
session_header: SessionHeader::new(config.model),
@@ -1329,6 +1335,7 @@ impl ChatWidget {
models_manager,
feedback,
skills,
model_family,
..
} = common;
let mut rng = rand::rng();
@@ -1353,6 +1360,7 @@ impl ChatWidget {
}),
active_cell: None,
config: config.clone(),
model_family,
auth_manager,
models_manager,
session_header: SessionHeader::new(config.model),
@@ -1785,7 +1793,7 @@ impl ChatWidget {
EventMsg::AgentReasoning(AgentReasoningEvent { .. }) => self.on_agent_reasoning_final(),
EventMsg::AgentReasoningRawContent(AgentReasoningRawContentEvent { text }) => {
self.on_agent_reasoning_delta(text);
self.on_agent_reasoning_final()
self.on_agent_reasoning_final();
}
EventMsg::AgentReasoningSectionBreak(_) => self.on_reasoning_section_break(),
EventMsg::TaskStarted(_) => self.on_task_started(),
@@ -2843,9 +2851,10 @@ impl ChatWidget {
}
/// Set the model in the widget's config copy.
pub(crate) fn set_model(&mut self, model: &str) {
pub(crate) fn set_model(&mut self, model: &str, model_family: ModelFamily) {
self.session_header.set_model(model);
self.config.model = model.to_string();
self.model_family = model_family;
}
pub(crate) fn add_info_message(&mut self, message: String, hint: Option<String>) {