agent: Only show compatible tools in profile selector (#40917)

In practice this just hides the web search tool when not using the Zed
provider

Release Notes:

- Fixed an issue where the web search tool would show up in the profile
selector even when not using a model via Zed Pro
This commit is contained in:
Bennet Fenner
2025-10-22 18:17:33 +00:00
committed by GitHub
parent cb7881ec0b
commit 6622902964
4 changed files with 29 additions and 12 deletions
+5 -5
View File
@@ -1857,7 +1857,7 @@ impl Thread {
.tools
.iter()
.filter_map(|(tool_name, tool)| {
if tool.supported_provider(&model.provider_id())
if tool.supports_provider(&model.provider_id())
&& profile.is_tool_enabled(tool_name)
{
Some((truncate(tool_name), tool.clone()))
@@ -2133,7 +2133,7 @@ where
/// Some tools rely on a provider for the underlying billing or other reasons.
/// Allow the tool to check if they are compatible, or should be filtered out.
fn supported_provider(&self, _provider: &LanguageModelProviderId) -> bool {
fn supports_provider(_provider: &LanguageModelProviderId) -> bool {
true
}
@@ -2174,7 +2174,7 @@ pub trait AnyAgentTool {
fn kind(&self) -> acp::ToolKind;
fn initial_title(&self, input: serde_json::Value, _cx: &mut App) -> SharedString;
fn input_schema(&self, format: LanguageModelToolSchemaFormat) -> Result<serde_json::Value>;
fn supported_provider(&self, _provider: &LanguageModelProviderId) -> bool {
fn supports_provider(&self, _provider: &LanguageModelProviderId) -> bool {
true
}
fn run(
@@ -2219,8 +2219,8 @@ where
Ok(json)
}
fn supported_provider(&self, provider: &LanguageModelProviderId) -> bool {
self.0.supported_provider(provider)
fn supports_provider(&self, provider: &LanguageModelProviderId) -> bool {
T::supports_provider(provider)
}
fn run(
+8 -2
View File
@@ -40,13 +40,19 @@ pub use web_search_tool::*;
macro_rules! tools {
($($tool:ty),* $(,)?) => {
/// A list of all built-in tool names
pub fn built_in_tool_names() -> impl Iterator<Item = String> {
pub fn supported_built_in_tool_names(provider: Option<language_model::LanguageModelProviderId>) -> impl Iterator<Item = String> {
[
$(
<$tool>::name().to_string(),
(if let Some(provider) = provider.as_ref() {
<$tool>::supports_provider(provider)
} else {
true
})
.then(|| <$tool>::name().to_string()),
)*
]
.into_iter()
.flatten()
}
/// A list of all built-in tools
+1 -1
View File
@@ -57,7 +57,7 @@ impl AgentTool for WebSearchTool {
}
/// We currently only support Zed Cloud as a provider.
fn supported_provider(&self, provider: &LanguageModelProviderId) -> bool {
fn supports_provider(provider: &LanguageModelProviderId) -> bool {
provider == &ZED_CLOUD_PROVIDER_ID
}