feat: improve tool loading (#2193)
This commit is contained in:
@@ -96,7 +96,7 @@ impl Agent {
|
||||
.extension_manager
|
||||
.lock()
|
||||
.await
|
||||
.get_prefixed_tools()
|
||||
.get_prefixed_tools(None)
|
||||
.await?;
|
||||
|
||||
// Add frontend tools directly - they don't need prefixing since they're already uniquely named
|
||||
@@ -271,21 +271,23 @@ impl Agent {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn list_tools(&self) -> Vec<Tool> {
|
||||
pub async fn list_tools(&self, extension_name: Option<String>) -> Vec<Tool> {
|
||||
let extension_manager = self.extension_manager.lock().await;
|
||||
let mut prefixed_tools = extension_manager
|
||||
.get_prefixed_tools()
|
||||
.get_prefixed_tools(extension_name.clone())
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
|
||||
// Add platform tools
|
||||
prefixed_tools.push(platform_tools::search_available_extensions_tool());
|
||||
prefixed_tools.push(platform_tools::enable_extension_tool());
|
||||
if extension_name.is_none() || extension_name.as_deref() == Some("platform") {
|
||||
// Add platform tools
|
||||
prefixed_tools.push(platform_tools::search_available_extensions_tool());
|
||||
prefixed_tools.push(platform_tools::enable_extension_tool());
|
||||
|
||||
// Add resource tools if supported
|
||||
if extension_manager.supports_resources() {
|
||||
prefixed_tools.push(platform_tools::read_resource_tool());
|
||||
prefixed_tools.push(platform_tools::list_resources_tool());
|
||||
// Add resource tools if supported
|
||||
if extension_manager.supports_resources() {
|
||||
prefixed_tools.push(platform_tools::read_resource_tool());
|
||||
prefixed_tools.push(platform_tools::list_resources_tool());
|
||||
}
|
||||
}
|
||||
|
||||
prefixed_tools
|
||||
@@ -580,7 +582,7 @@ impl Agent {
|
||||
|
||||
pub async fn get_plan_prompt(&self) -> anyhow::Result<String> {
|
||||
let extension_manager = self.extension_manager.lock().await;
|
||||
let tools = extension_manager.get_prefixed_tools().await?;
|
||||
let tools = extension_manager.get_prefixed_tools(None).await?;
|
||||
let tools_info = tools
|
||||
.into_iter()
|
||||
.map(|tool| {
|
||||
@@ -612,7 +614,7 @@ impl Agent {
|
||||
.build_system_prompt(extensions_info, self.frontend_instructions.clone());
|
||||
|
||||
let recipe_prompt = self.prompt_manager.get_recipe_prompt().await;
|
||||
let tools = extension_manager.get_prefixed_tools().await?;
|
||||
let tools = extension_manager.get_prefixed_tools(None).await?;
|
||||
|
||||
messages.push(Message::user().with_text(recipe_prompt));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user