mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Add default model provider selection to the app server (#61397)
## What changed Add `modelProvider/default/set` with a `providerId` parameter to persist the default provider for new threads and model lists. Return `ConfigWriteResponse`, reject unconfigured providers, and respect managed requirements, read-only configuration, and CLI overrides. Reload the model catalog on its next read when the default changes effectively. Resolve explicit `model/list` provider selections against the current catalog configuration so clients can continue listing models for a retained provider after switching defaults. Update the protocol schemas, generated TypeScript and Python types, and app-server documentation. ## Testing Add coverage for switching defaults and switching back, rejecting unknown providers without changing the catalog, retaining explicit provider selections, reporting CLI overrides, and rejecting writes blocked by configuration restrictions. GitOrigin-RevId: 3615835f58045d33a21b3c57d47932d6d1e3fb12
This commit is contained in:
@@ -187,12 +187,10 @@ impl CatalogRequestProcessor {
|
||||
let (config, models_manager) = match params.model_provider.as_deref() {
|
||||
None => (active_config, active_models_manager),
|
||||
Some(provider_id) => {
|
||||
let config = config_for_provider(&self.config, provider_id)?;
|
||||
if provider_id == active_config.model_provider_id
|
||||
&& config.model_provider == active_config.model_provider
|
||||
{
|
||||
if provider_id == active_config.model_provider_id {
|
||||
(active_config, active_models_manager)
|
||||
} else {
|
||||
let config = config_for_provider(&active_config, provider_id)?;
|
||||
// Temporary catalogs must not replace the active provider's disk cache.
|
||||
let manager = self.thread_manager.temporary_models_manager_for_config(
|
||||
&config,
|
||||
|
||||
@@ -240,6 +240,25 @@ impl ConfigRequestProcessor {
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
pub(crate) fn model_provider_default_set(
|
||||
&self,
|
||||
params: codex_app_server_protocol::ModelProviderDefaultSetParams,
|
||||
) -> futures::future::BoxFuture<'_, Result<ClientResponsePayload, JSONRPCErrorError>> {
|
||||
// Keep provider config resolution off the shared request dispatcher stack.
|
||||
Box::pin(async move {
|
||||
let result = self
|
||||
.config_manager
|
||||
.model_provider_default_set(params)
|
||||
.await
|
||||
.map_err(map_error);
|
||||
let response = self.handle_config_mutation_result(result).await?;
|
||||
if response.status == codex_app_server_protocol::WriteStatus::Ok {
|
||||
self.model_catalog.invalidate().await;
|
||||
}
|
||||
Ok(ClientResponsePayload::ModelProviderDefaultSet(response))
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn model_provider_capabilities_read(
|
||||
&self,
|
||||
) -> Result<ModelProviderCapabilitiesReadResponse, JSONRPCErrorError> {
|
||||
|
||||
Reference in New Issue
Block a user