Enforce strict tool name collision errors (#37020)

## What changed

- Track the first duplicate effective tool name while assembling the tool registry, including collisions introduced by external tools, code mode, and tool search.
- When `[features.tool_registry].error_on_tool_collisions` is enabled, fail the turn with a `duplicate tool: <namespace>.<name>` error before sending a model request.
- Continue allowing identical tool names in different namespaces, and preserve the existing collision behavior when strict checking is disabled.

## Testing

- Cover registry collision tracking, strict tool planning across tool sources, namespace isolation, failure before sampling, and pre-sampling compaction.

GitOrigin-RevId: 4cf83538fb513cec0b9c8b567780caaaadd3243d
This commit is contained in:
rka-oai
2026-08-05 03:52:11 +00:00
committed by copyberry
parent 5d89ab65dc
commit 1e489adad0
13 changed files with 374 additions and 17 deletions

View File

@@ -654,9 +654,9 @@ pub fn canonical_feature_for_key(key: &str) -> Option<Feature> {
.map(|spec| spec.id)
}
/// Returns `true` if the provided string matches a known feature toggle key.
/// Returns `true` if the provided string matches a known `[features]` key.
pub fn is_known_feature_key(key: &str) -> bool {
feature_for_key(key).is_some()
key == "tool_registry" || feature_for_key(key).is_some()
}
/// Deserializable features table for TOML.

View File

@@ -40,7 +40,8 @@ fn tool_registry_config_is_not_a_feature_toggle() {
})
);
assert!(features.entries().is_empty());
assert!(!crate::is_known_feature_key("tool_registry"));
assert!(crate::is_known_feature_key("tool_registry"));
assert_eq!(feature_for_key("tool_registry"), None);
}
#[test]