A platform for community discussion. Free, open, simple.
FIX: Make flag tool argument more obvious to avoid false-positives (#37018)
Roman Rizzifff96df8be0c
diff --git a/plugins/discourse-ai/config/locales/server.en.yml b/plugins/discourse-ai/config/locales/server.en.ymlindex 96a80d9fa98..e7e9b278775 100644--- a/plugins/discourse-ai/config/locales/server.en.yml+++ b/plugins/discourse-ai/config/locales/server.en.yml@@ -576,7 +576,7 @@ en:github_diff: "<a href='%{url}'>%{repo} %{ref}</a>"github_file_content: "Retrieved content of %{file_paths} from %{repo_name}@%{branch}"random_picker: "Picking from %{options}, picked: %{result}"- flag_post: "Flagging post %{post_id} (verdict: %{verdict})"+ flag_post: "Flagging post %{post_id} (flag_post: %{flag_post})"read: "Reading: <a href='%{url}'>%{title}</a>"time: "Time in %{timezone} is %{time}"summarize: "Summarized <a href='%{url}'>%{title}</a>"diff --git a/plugins/discourse-ai/lib/personas/tools/flag_post.rb b/plugins/discourse-ai/lib/personas/tools/flag_post.rbindex 0313828a6bf..194fccd9033 100644--- a/plugins/discourse-ai/lib/personas/tools/flag_post.rb+++ b/plugins/discourse-ai/lib/personas/tools/flag_post.rb@@ -16,10 +16,10 @@ module DiscourseAidef self.signature{name: name,- description: "Flags the current post for review when verdict is true.",+ description: "Flags the current post for review when flag_post is true.",parameters: [{- name: "verdict",+ name: "flag_post",description: "Whether the post should be flagged",type: "boolean",required: true,@@ -42,8 +42,8 @@ module DiscourseAi"flag_post"end- def verdict- !!parameters[:verdict]+ def flag_post+ !!parameters[:flag_post]enddef reason@@ -64,7 +64,7 @@ module DiscourseAireturn error_response(I18n.t("discourse_ai.ai_bot.flag_post.errors.invalid_flag_type"))end- if !verdict+ if !flag_postreturn { status: "skipped", message: I18n.t("discourse_ai.ai_bot.flag_post.skipped") }end@@ -132,7 +132,7 @@ module DiscourseAienddef description_args- { post_id: post&.id, verdict: verdict, flag_type: flag_type }+ { post_id: post&.id, flag_post:, flag_type: }endprivatediff --git a/plugins/discourse-ai/spec/lib/modules/automation/llm_triage_spec.rb b/plugins/discourse-ai/spec/lib/modules/automation/llm_triage_spec.rbindex 68919422d6d..c5f0c8d2c9e 100644--- a/plugins/discourse-ai/spec/lib/modules/automation/llm_triage_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/automation/llm_triage_spec.rb@@ -102,7 +102,7 @@ describe DiscourseAi::Automation::LlmTriage doDiscourseAi::Completions::ToolCall.new(name: "flag_post",parameters: {- verdict: true,+ flag_post: true,reason: "Looks unsafe",},id: "tool_call_1",diff --git a/plugins/discourse-ai/spec/lib/personas/tools/flag_post_spec.rb b/plugins/discourse-ai/spec/lib/personas/tools/flag_post_spec.rbindex 48ccc9e986d..1470894d5ec 100644--- a/plugins/discourse-ai/spec/lib/personas/tools/flag_post_spec.rb+++ b/plugins/discourse-ai/spec/lib/personas/tools/flag_post_spec.rb@@ -24,10 +24,10 @@ RSpec.describe DiscourseAi::Personas::Tools::FlagPost dolet(:context) { DiscourseAi::Personas::BotContext.new(post: post) }- it "flags the post when verdict is true" do+ it "flags the post when flag_post is true" doresult = nil- expect { result = tool(verdict: true, reason: "Clear spam").invoke }.to change {+ expect { result = tool(flag_post: true, reason: "Clear spam").invoke }.to change {ReviewablePost.count}.by(1)@@ -42,10 +42,10 @@ RSpec.describe DiscourseAi::Personas::Tools::FlagPost doexpect(score.reason).to include("Clear spam")end- it "skips when verdict is false" do+ it "skips when flag_post is false" doresult = nil- expect { result = tool(verdict: false, reason: "Does not matter").invoke }.not_to change {+ expect { result = tool(flag_post: false, reason: "Does not matter").invoke }.not_to change {ReviewablePost.count}@@ -63,7 +63,7 @@ RSpec.describe DiscourseAi::Personas::Tools::FlagPost doresult = nil- expect { result = tool(verdict: true, reason: "Duplicate flag").invoke }.not_to change {+ expect { result = tool(flag_post: true, reason: "Duplicate flag").invoke }.not_to change {ReviewableScore.count}@@ -71,7 +71,7 @@ RSpec.describe DiscourseAi::Personas::Tools::FlagPost doendit "returns an error when reason is blank" do- result = tool(verdict: true, reason: " ").invoke+ result = tool(flag_post: true, reason: " ").invokeexpect(result[:status]).to eq("error")end@@ -79,7 +79,7 @@ RSpec.describe DiscourseAi::Personas::Tools::FlagPost doit "applies the configured flag_type option" doresult =tool(- { verdict: true, reason: "Needs review" },+ { flag_post: true, reason: "Needs review" },persona_options: {flag_type: "review_hide",},