mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
## What changed - Share a lazily registered runtime across threads, model discovery, and extension clients when `runtime_agent_instances` is enabled, while honoring each thread's authentication mode and credential owner. - Bind model catalogs to the effective provider and authentication context while preserving cache policy and live API-key discovery settings. - Resolve credentials, routing, and transport policy together for each request. Preserve proxy and TLS settings, validate runtime account selectors, and prevent pooled connections from crossing runtime identities. - Accept supported ChatGPT subdomains when selecting the registration environment. ## Testing Add integration coverage for shared runtime registration, dual-header and assertion-only modes, disabled and third-party providers, credential replacement, subagents, and delegated review. Add coverage for catalog cache policy and runtime-aware connection reuse. GitOrigin-RevId: 99dd9d987c29c93597a648f6586f98ac6a932c3c
40 lines
1.6 KiB
Rust
40 lines
1.6 KiB
Rust
//! Host catalog construction from the provider and credentials selected for a thread.
|
|
|
|
use crate::SharedModelProvider;
|
|
use codex_models_manager::manager::ModelCatalogSettings;
|
|
use codex_models_manager::manager::SharedModelsManager;
|
|
use codex_protocol::openai_models::ModelsResponse;
|
|
|
|
/// Builds catalogs for the selected provider while retaining the host's cache policy.
|
|
/// Provider-backed implementations must use the supplied provider, which carries the
|
|
/// current credential owner and runtime mode. Hosts may also supply independent metadata.
|
|
pub trait ModelCatalogFactory: Send + Sync {
|
|
fn build(
|
|
&self,
|
|
provider: SharedModelProvider,
|
|
config_model_catalog: Option<ModelsResponse>,
|
|
api_key_model_discovery_default: bool,
|
|
) -> SharedModelsManager;
|
|
|
|
/// Publish a live discovery setting to existing and future catalogs.
|
|
/// Sources that do not perform API-key discovery may ignore it.
|
|
fn set_api_key_model_discovery_enabled(&self, _enabled: bool) {}
|
|
}
|
|
|
|
impl ModelCatalogFactory for ModelCatalogSettings {
|
|
fn build(
|
|
&self,
|
|
provider: SharedModelProvider,
|
|
config_model_catalog: Option<ModelsResponse>,
|
|
api_key_model_discovery_default: bool,
|
|
) -> SharedModelsManager {
|
|
let mut settings = self.clone();
|
|
settings.api_key_model_discovery_default = api_key_model_discovery_default;
|
|
provider.models_manager_with_settings(config_model_catalog, settings)
|
|
}
|
|
|
|
fn set_api_key_model_discovery_enabled(&self, enabled: bool) {
|
|
ModelCatalogSettings::set_api_key_model_discovery_enabled(self, enabled);
|
|
}
|
|
}
|