Skip to content

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

DEV: Add update site settings tool to settings explorer agent (#41771)

Penar Musarajdbb9d7921ae3
diff --git a/plugins/discourse-ai/lib/agents/settings_explorer.rb b/plugins/discourse-ai/lib/agents/settings_explorer.rb
index d01c5ce37fc..30d5e346836 100644
--- a/plugins/discourse-ai/lib/agents/settings_explorer.rb
+++ b/plugins/discourse-ai/lib/agents/settings_explorer.rb
@@ -4,7 +4,7 @@ module DiscourseAi
module Agents
class SettingsExplorer < Agent
def tools
- [Tools::SettingContext, Tools::SearchSettings]
+ [Tools::SettingContext, Tools::SearchSettings, Tools::ChangeSiteSetting]
end
def system_prompt
@@ -13,6 +13,7 @@ module DiscourseAi
- You are able to find information about all the site settings.
- You are able to request context for a specific setting.
+ - You are able to update site settings when an administrator asks you to do so, but you must get approval from a human before making any change.
- You are a helpful teacher that teaches people about what each settings does.
- Keep in mind that setting names are always a single word separated by underscores. eg. 'site_description'
diff --git a/plugins/discourse-ai/spec/lib/agents/settings_explorer_spec.rb b/plugins/discourse-ai/spec/lib/agents/settings_explorer_spec.rb
index 6616b55ae8c..4884a2e4360 100644
--- a/plugins/discourse-ai/spec/lib/agents/settings_explorer_spec.rb
+++ b/plugins/discourse-ai/spec/lib/agents/settings_explorer_spec.rb
@@ -5,6 +5,12 @@ RSpec.describe DiscourseAi::Agents::SettingsExplorer do
before { enable_current_plugin }
+ it "requires human approval before updating settings for administrators" do
+ expect(settings_explorer.system_prompt).to include(
+ "You are able to update site settings when an administrator asks you to do so, but you must get approval from a human before making any change.",
+ )
+ end
+
it "renders schema" do
prompt = settings_explorer.system_prompt
@@ -14,7 +20,11 @@ RSpec.describe DiscourseAi::Agents::SettingsExplorer do
expect(prompt).to include("site_description")
expect(settings_explorer.tools).to eq(
- [DiscourseAi::Agents::Tools::SettingContext, DiscourseAi::Agents::Tools::SearchSettings],
+ [
+ DiscourseAi::Agents::Tools::SettingContext,
+ DiscourseAi::Agents::Tools::SearchSettings,
+ DiscourseAi::Agents::Tools::ChangeSiteSetting,
+ ],
)
end
end