Skip to content

A platform for community discussion. Free, open, simple.

DEV: Drop the `custom?` workaround from plugin AI tools

Régis Hanol66846f7f3d48
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/find_queries.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/find_queries.rb
index 1495f42b73c..0ace729aa01 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/find_queries.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/find_queries.rb
@@ -31,10 +31,6 @@ module DiscourseDataExplorer
}
end
- def self.custom?
- true
- end
-
def self.name
"find_queries"
end
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/run_sql.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/run_sql.rb
index 3d2773fdf72..2eeda83eb31 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/run_sql.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/run_sql.rb
@@ -22,10 +22,6 @@ module DiscourseDataExplorer
}
end
- def self.custom?
- true
- end
-
def self.name
"run_sql"
end
diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/submit_query.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/submit_query.rb
index 5e01edd1fa1..baf88f63891 100644
--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/submit_query.rb
+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/tools/submit_query.rb
@@ -35,10 +35,6 @@ module DiscourseDataExplorer
}
end
- def self.custom?
- true
- end
-
def self.name
"submit_query"
end
diff --git a/plugins/discourse-workflows/lib/discourse_workflows/ai/tools/base.rb b/plugins/discourse-workflows/lib/discourse_workflows/ai/tools/base.rb
index 82dba68242a..552495d10ed 100644
--- a/plugins/discourse-workflows/lib/discourse_workflows/ai/tools/base.rb
+++ b/plugins/discourse-workflows/lib/discourse_workflows/ai/tools/base.rb
@@ -4,10 +4,6 @@ module DiscourseWorkflows
module Ai
module Tools
class Base < DiscourseAi::Agents::Tools::Tool
- def self.custom?
- true
- end
-
private
def ensure_can_manage_workflows!
diff --git a/plugins/discourse-workflows/plugin.rb b/plugins/discourse-workflows/plugin.rb
index 42085e59756..e5911b46bfc 100644
--- a/plugins/discourse-workflows/plugin.rb
+++ b/plugins/discourse-workflows/plugin.rb
@@ -229,6 +229,14 @@ after_initialize do
enabled_by_setting: "discourse_workflows_ai_authoring_enabled",
plugin: self,
)
+
+ DiscourseAi.register_tools(
+ [
+ DiscourseWorkflows::Ai::Tools::SearchChatChannels,
+ DiscourseWorkflows::Ai::Tools::SearchChatIntegrationChannels,
+ ],
+ plugin: self,
+ )
end
add_to_serializer :site,
diff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/ai_workflow_author_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/ai_workflow_author_spec.rb
index 2fa4a21a2da..7f932f58d14 100644
--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/ai_workflow_author_spec.rb
+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/ai_workflow_author_spec.rb
@@ -51,6 +51,19 @@ RSpec.describe DiscourseWorkflows::AiWorkflowAuthor do
expect(described_class.new.tools).to include(DiscourseWorkflows::Ai::Tools::SearchChatChannels)
end
+ it "keeps chat channel search available when chat is enabled after the tool registry is cached" do
+ skip "Chat plugin is not available" if !defined?(::Chat::Channel)
+
+ SiteSetting.chat_enabled = false
+ described_class.instance_variable_set(:@external_registry_signature, nil)
+ described_class.new.available_tools
+
+ SiteSetting.chat_enabled = true
+ expect(described_class.new.available_tools).to include(
+ DiscourseWorkflows::Ai::Tools::SearchChatChannels,
+ )
+ end
+
it "includes external chat integration channel search only when the integration is enabled" do
skip "Chat Integration plugin is not available" if !defined?(DiscourseChatIntegration::Channel)