mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Use thread-scoped model catalogs for model lookups (#61421)
## Why Model lookups through the startup catalog can use the wrong provider's capabilities or instructions after a default provider switch or when a thread has its own catalog. ## What changed - Resolve model metadata for sampling, prediction forks, and memory writes through the owning thread's catalog. - Make the thread's models manager available to extensions before startup callbacks and use it for guardian sampler configuration. - Import external sessions using the destination provider and originator's catalog, loading its offline cache only when no refreshed catalog is available. ## Testing Add regression coverage for sampling after a default provider switch, parent-specific prediction fork capabilities, thread-scoped model lookups, and imported sessions retaining destination provider instructions and originator. GitOrigin-RevId: c86081b9e55c5e2b42a7f082966485d7fb5139d4
This commit is contained in:
@@ -432,12 +432,23 @@ impl ExternalAgentSessionImporter {
|
||||
format!("failed to load imported session config: {err}"),
|
||||
)
|
||||
})?;
|
||||
let models_manager = self.thread_manager.get_models_manager();
|
||||
let originator = codex_login::default_client::originator().value;
|
||||
let models_manager = self.thread_manager.models_manager_for_config(&config);
|
||||
let models_manager = models_manager
|
||||
.for_originator(&originator)
|
||||
.unwrap_or(models_manager);
|
||||
// A pinned model skips discovery. Load its destination cache without fetching or
|
||||
// replacing a provider response that is already in memory.
|
||||
if models_manager.refreshed_model_catalog().is_none() {
|
||||
models_manager
|
||||
.list_models(RefreshStrategy::Offline, config.http_client_factory())
|
||||
.await;
|
||||
}
|
||||
let model = models_manager
|
||||
.get_default_model(
|
||||
&config.model,
|
||||
/*allow_provider_model_fallback*/ false,
|
||||
RefreshStrategy::Offline,
|
||||
RefreshStrategy::InMemory,
|
||||
config.http_client_factory(),
|
||||
)
|
||||
.await;
|
||||
@@ -465,7 +476,7 @@ impl ExternalAgentSessionImporter {
|
||||
parent_thread_id: None,
|
||||
source: source.clone(),
|
||||
thread_source: None,
|
||||
originator: codex_login::default_client::originator().value,
|
||||
originator,
|
||||
base_instructions: BaseInstructions {
|
||||
text: config
|
||||
.base_instructions
|
||||
|
||||
@@ -5435,10 +5435,8 @@ impl ThreadRequestProcessor {
|
||||
.items()
|
||||
.any(|item| matches!(item, ResponseItem::AdditionalTools { .. }))
|
||||
&& let Some(model) = options.config.model.as_deref()
|
||||
&& self
|
||||
.thread_manager
|
||||
.get_models_manager()
|
||||
.get_model_info(model, &options.config.to_models_manager_config())
|
||||
&& parent
|
||||
.model_info(model, &options.config.to_models_manager_config())
|
||||
.await
|
||||
.use_responses_lite
|
||||
{
|
||||
|
||||
@@ -182,9 +182,8 @@ impl SampleTask {
|
||||
})
|
||||
.await
|
||||
.map_err(|error| internal_error(error.to_string()))?;
|
||||
let model = manager
|
||||
.get_models_manager()
|
||||
.get_model_info(
|
||||
let model = parent
|
||||
.model_info(
|
||||
options.config.model.as_deref().unwrap_or(&snapshot.model),
|
||||
&options.config.to_models_manager_config(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user