fix(acp): resolve provider default model instead of leaking sentinel "current" (#10305)
Co-authored-by: Jack Amadeo <jackamadeo@squareup.com>
This commit is contained in:
@@ -3056,7 +3056,11 @@ impl GooseAcpAgent {
|
||||
.get_goose_model()
|
||||
.internal_err_ctx("Failed to resolve default model from config")?
|
||||
} else if is_changing_provider {
|
||||
ACP_CURRENT_MODEL.to_string()
|
||||
crate::providers::get_from_registry(&resolved_provider_name)
|
||||
.await
|
||||
.ok()
|
||||
.map(|entry| entry.metadata().default_model.clone())
|
||||
.unwrap_or(ACP_CURRENT_MODEL.to_string())
|
||||
} else {
|
||||
current_model
|
||||
};
|
||||
|
||||
@@ -2897,7 +2897,7 @@ impl Agent {
|
||||
.or_else(|| config.get_goose_provider().ok())
|
||||
.ok_or_else(|| anyhow!("Could not configure agent: missing provider"))?;
|
||||
|
||||
let model_config = match session.model_config.clone() {
|
||||
let mut model_config = match session.model_config.clone() {
|
||||
Some(saved_config) => saved_config,
|
||||
None => {
|
||||
let model_name = config
|
||||
@@ -2909,6 +2909,20 @@ impl Agent {
|
||||
}
|
||||
};
|
||||
|
||||
// if the saved model is the ACP sentinel "current", only preserve this if the provider
|
||||
// uses this sentinel to indicate it's an ACP provider that manages its model
|
||||
if model_config.model_name == crate::acp::ACP_CURRENT_MODEL {
|
||||
if let Ok(entry) = crate::providers::get_from_registry(&provider_name).await {
|
||||
if entry.metadata().default_model != crate::acp::ACP_CURRENT_MODEL {
|
||||
model_config = crate::model_config::model_config_from_user_config(
|
||||
&provider_name,
|
||||
&entry.metadata().default_model,
|
||||
)
|
||||
.map_err(|e| anyhow!("Could not resolve default model: {}", e))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let extensions =
|
||||
EnabledExtensionsState::extensions_or_default(Some(&session.extension_data), config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user