Restrict shell_command to a single local environment (#36329)

## What changed

- Register the legacy `shell_command` handler only when exactly one local environment is available, including when unified exec keeps it hidden for compatibility.
- Reserve the unnamespaced `shell_command` name so external tools cannot claim it when the built-in handler is unavailable. Namespaced tools with that name remain supported.

## Testing

- Cover remote and multiple-environment tool plans, unified exec routing, and external tool registration for reserved and namespaced variants.

GitOrigin-RevId: 93834539b31ac8a7fea072bfa4de792bcc3e053b
This commit is contained in:
jif authored and copyberry committed 2026-07-31 14:01:29 +00:00
1 parent 66d63afd18
commit ef293f7ac9
5 files changed
+137 -11

No files matched your search

+7 -1
View File
@@ -384,7 +384,13 @@ impl ToolRegistry {
}
pub(crate) fn register_external(&mut self, runtime: Arc<dyn CoreToolRuntime>) -> bool {
match self.tools.entry(runtime.tool_name()) {
let tool_name = runtime.tool_name();
if tool_name.namespace.is_none() && tool_name.name == "shell_command" {
tracing::warn!(tool_name = %tool_name, "skipping external tool with reserved name");
return false;
}
match self.tools.entry(tool_name) {
Entry::Vacant(entry) => {
entry.insert(runtime);
true