Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions crates/goose/src/agents/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::platform_tools;
use super::tool_execution::{ToolCallResult, CHAT_MODE_TOOL_SKIPPED_RESPONSE, DECLINED_RESPONSE};
use crate::action_required_manager::ActionRequiredManager;
use crate::agents::extension::{ExtensionConfig, ExtensionResult, ToolInfo};
use crate::agents::extension_manager::{get_parameter_names, normalize, ExtensionManager};
use crate::agents::extension_manager::{get_parameter_names, ExtensionManager};
use crate::agents::extension_manager_extension::MANAGE_EXTENSIONS_TOOL_NAME_COMPLETE;
use crate::agents::final_output_tool::{FINAL_OUTPUT_CONTINUATION_MESSAGE, FINAL_OUTPUT_TOOL_NAME};
use crate::agents::platform_tools::PLATFORM_MANAGE_SCHEDULE_TOOL_NAME;
Expand Down Expand Up @@ -659,11 +659,10 @@ impl Agent {

async move {
let name = config_clone.name().to_string();
let normalized_name = normalize(&name);

if agent_ref
.extension_manager
.is_extension_enabled(&normalized_name)
.is_extension_enabled(&name)
.await
{
tracing::debug!("Extension {} already loaded, skipping", name);
Expand Down
16 changes: 11 additions & 5 deletions crates/goose/src/agents/extension_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,11 @@ impl ExtensionManager {
info: Option<ServerInfo>,
temp_dir: Option<TempDir>,
) {
let normalized = normalize(&name);
self.extensions
.lock()
.await
.insert(name, Extension::new(config, client, info, temp_dir));
.insert(normalized, Extension::new(config, client, info, temp_dir));
self.invalidate_tools_cache_and_bump_version().await;
}

Expand Down Expand Up @@ -690,7 +691,8 @@ impl ExtensionManager {
}

pub async fn is_extension_enabled(&self, name: &str) -> bool {
self.extensions.lock().await.contains_key(name)
let normalized = normalize(name);
self.extensions.lock().await.contains_key(&normalized)
}

pub async fn get_extension_configs(&self) -> Vec<ExtensionConfig> {
Expand Down Expand Up @@ -722,18 +724,21 @@ impl ExtensionManager {
extension_name: Option<&str>,
exclude: Option<&str>,
) -> Vec<Tool> {
let extension_name_normalized = extension_name.map(normalize);
let exclude_normalized = exclude.map(normalize);

tools
.iter()
.filter(|tool| {
let tool_prefix = tool.name.as_ref().split("__").next().unwrap_or("");

if let Some(excluded) = exclude {
if let Some(ref excluded) = exclude_normalized {
if tool_prefix == excluded {
return false;
}
}

if let Some(name_filter) = extension_name {
if let Some(ref name_filter) = extension_name_normalized {
tool_prefix == name_filter
} else {
true
Expand Down Expand Up @@ -1354,10 +1359,11 @@ impl ExtensionManager {
}

async fn get_server_client(&self, name: impl Into<String>) -> Option<McpClientBox> {
let normalized = normalize(&name.into());
self.extensions
.lock()
.await
.get(&name.into())
.get(&normalized)
.map(|ext| ext.get_client())
}

Expand Down