Preserve selected profile settings over managed new-thread defaults (#44693)

## Why

Managed new-thread defaults could overwrite model, reasoning effort, and service tier settings from an explicitly selected profile.

## What changed

- Treat effective profile settings as explicit launch choices when applying managed defaults. A profile setting for either `model` or `model_reasoning_effort` opts out of both managed values; `service_tier` remains independent.
- Count a profile setting only when it supplies the highest-precedence active value, so settings shadowed by project configuration do not block defaults.

## Testing

Add regression coverage for profile precedence at startup, session replacement, and background task creation, plus custom-provider profiles, service tiers, unrelated profile settings, and project settings that shadow profiles.

GitOrigin-RevId: 98f036b8b7059bab8598283600dbc6967c71d3e3
This commit is contained in:
Alex Ryan authored and copyberry committed 2026-09-11 00:59:27 +00:00
1 parent e53c444964
commit aff3e0db94
7 files changed
+140 -18

No files matched your search

@@ -416,6 +416,7 @@ async fn background_task_preserves_explicit_choices_and_managed_defaults() -> Re
("saved", "server-model", "high"),
("cli_effort", "server-model", "low"),
("profile_model", "profile-model", "high"),
("profile_managed", "profile-model", "low"),
("managed", "managed-model", "medium"),
] {
let client_home = tempdir()?;
@@ -428,7 +429,7 @@ async fn background_task_preserves_explicit_choices_and_managed_defaults() -> Re
server_home.path().join("config.toml"),
"model = \"server-model\"\nmodel_reasoning_effort = \"high\"\n",
)?;
if choice == "managed" || choice.starts_with("cli_") {
if choice == "managed" || choice == "profile_managed" || choice.starts_with("cli_") {
std::fs::write(
server_home.path().join("requirements.toml"),
"[models.new_thread]\nmodel = \"managed-model\"\nmodel_reasoning_effort = \"medium\"\n",
@@ -440,9 +441,16 @@ async fn background_task_preserves_explicit_choices_and_managed_defaults() -> Re
"model_reasoning_effort".into(),
TomlValue::String("low".into()),
)),
"profile_model" => {
"profile_model" | "profile_managed" => {
let path = client_home.path().join("work.config.toml");
std::fs::write(&path, "model = \"profile-model\"\n")?;
std::fs::write(
&path,
if choice == "profile_managed" {
"model = \"profile-model\"\nmodel_reasoning_effort = \"low\"\n"
} else {
"model = \"profile-model\"\n"
},
)?;
app.loader_overrides.user_config_path = Some(path.abs());
app.loader_overrides.user_config_profile = Some("work".parse()?);
}