Add opt-in model discovery for OpenAI API keys (#44392)

## What changed

Add the default-off `api_key_model_discovery` feature and expose it through app-server experimental feature enablement, respecting user configuration overrides.

When enabled, fetch OpenAI API-key model metadata from the Codex backend, honoring explicit provider base URLs. Treat remote catalogs containing visible models as authoritative. When disabled at startup, skip discovery requests and cached catalogs and retain bundled models.

## Testing

Add coverage for feature enablement and user overrides, cached catalogs across sessions, provider routing, and API-key `model/list` results. Extend coverage for remote instructions and auth-specific cache isolation.

GitOrigin-RevId: 4b189c37c615a7f808cb6ff5f0858a9a55f36ebc
This commit is contained in:
andrewgu-oai
2026-09-10 03:18:28 +00:00
committed by copyberry
parent 5a9eb145c4
commit ea53c8d4f7
13 changed files with 465 additions and 54 deletions
@@ -63,6 +63,7 @@ const BACKGROUND_PAGINATED_ROLLOUT_MIGRATION_FEATURE: &str =
"background_paginated_rollout_migration";
const SUPPORTED_EXPERIMENTAL_FEATURE_ENABLEMENT: &[&str] = &[
"api_key_model_discovery",
"auth_elicitation",
BACKGROUND_PAGINATED_ROLLOUT_MIGRATION_FEATURE,
"codex_apps_mcp_2026_07_28",
@@ -315,6 +316,11 @@ impl ConfigRequestProcessor {
.map_err(|_| internal_error("failed to update feature enablement"))?;
let config = self.load_latest_config(/*fallback_cwd*/ None).await?;
self.thread_manager
.get_models_manager()
.set_api_key_model_discovery_enabled(
config.features.enabled(Feature::ApiKeyModelDiscovery),
);
if should_start_background_rollout_migration && config.features.enabled(feature) {
self.thread_manager.start_background_rollout_migration();
}