Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 5fc7a73

Browse files
authored
FIX: Triage rule should append selected tags instead of replacing them (#1022)
1 parent 34f43f3 commit 5fc7a73

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/automation/llm_triage.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def self.handle(
6666

6767
changes = {}
6868
changes[:category_id] = category_id if category_id.present?
69-
changes[:tags] = tags if SiteSetting.tagging_enabled? && tags.present?
69+
if SiteSetting.tagging_enabled? && tags.present?
70+
changes[:tags] = post.topic.tags.map(&:name).concat(tags)
71+
end
7072

7173
if changes.present?
7274
first_post = post.topic.posts.where(post_number: 1).first

spec/lib/modules/automation/llm_triage_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,24 @@ def triage(**args)
198198
expect(spy.model_params[:stop_sequences]).to contain_exactly(*sequences)
199199
end
200200
end
201+
202+
it "append rule tags instead of replacing them" do
203+
tag_1 = Fabricate(:tag)
204+
tag_2 = Fabricate(:tag)
205+
post.topic.update!(tags: [tag_1])
206+
207+
DiscourseAi::Completions::Llm.with_prepared_responses(["bad"]) do
208+
triage(
209+
post: post,
210+
model: "custom:#{llm_model.id}",
211+
system_prompt: "test %%POST%%",
212+
search_for_text: "bad",
213+
flag_post: true,
214+
tags: [tag_2.name],
215+
automation: nil,
216+
)
217+
end
218+
219+
expect(post.topic.reload.tags).to contain_exactly(tag_1, tag_2)
220+
end
201221
end

0 commit comments

Comments
 (0)