Preserve project agent opt-ins across enabled legacy feature flags (#59496)

## Why

An enabled legacy feature flag could prevent a project's `agents.enabled = true` from overriding a lower-priority legacy opt-out, leaving V1 agent tools unavailable.

## What changed

Only stop scanning configuration layers at an explicit legacy feature opt-out. Enabled flags now allow the scan to continue, so project opt-ins can override lower-priority opt-outs while same-layer and higher-priority opt-outs remain effective.

## Testing

Extend the model runtime selector regression test to cover enabled `features.collab` flags in project configuration and CLI overrides, and verify that explicit `false` values still disable V1 agent tools.

GitOrigin-RevId: ca3dcf9dc6a642eb72e20929776fb74379715053
This commit is contained in:
jif
2026-11-04 21:23:11 +00:00
committed by copyberry
parent 464239de0a
commit b260ee5e83
2 changed files with 33 additions and 3 deletions
+3 -3
View File
@@ -23,9 +23,9 @@ pub(super) fn project_overrides_legacy_subagent_opt_out(layers: &ConfigLayerStac
let mut project_enabled = false;
for layer in layers.layers_high_to_low() {
if let Some(features) = layer.config.get("features").and_then(toml::Value::as_table)
&& features
.keys()
.any(|key| feature_for_key(key) == Some(Feature::Collab))
&& features.iter().any(|(key, enabled)| {
enabled.as_bool() == Some(false) && feature_for_key(key) == Some(Feature::Collab)
})
{
return project_enabled;
}
@@ -447,6 +447,36 @@ async fn migrating_only_the_project_agent_setting_preserves_v1_tools() -> Result
Some("multi_agent_v1"),
),
(migrated, config(), None, Some("multi_agent_v1")),
(
"[features]\nmulti_agent = true",
config().cli_overrides(vec![("features.collab".to_string(), true.into())]),
None,
Some("multi_agent_v1"),
),
(
migrated,
config().cli_overrides(vec![("features.collab".to_string(), true.into())]),
None,
Some("multi_agent_v1"),
),
(
"[agents]\nenabled = true\n[features]\ncollab = true",
config(),
None,
Some("multi_agent_v1"),
),
(
"[agents]\nenabled = true\n[features]\ncollab = false",
config(),
None,
None,
),
(
migrated,
config().cli_overrides(vec![("features.collab".to_string(), false.into())]),
None,
None,
),
(
migrated,
config(),