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

Commit 9beca96

Browse files
committed
FIX: forced tools wasn't set correctly when tool has no options.
1 parent b37aa96 commit 9beca96

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

assets/javascripts/discourse/admin/models/ai-persona.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ export default class AiPersona extends RestModel {
7777

7878
flattenedToolStructure(data) {
7979
return (data.tools || []).map((tName) => {
80-
return [tName, data.toolOptions[tName], data.forcedTools.includes(tName)];
80+
return [
81+
tName,
82+
data.toolOptions[tName] || {},
83+
data.forcedTools.includes(tName),
84+
];
8185
});
8286
}
8387

@@ -138,6 +142,8 @@ export default class AiPersona extends RestModel {
138142
const dataClone = JSON.parse(JSON.stringify(data));
139143

140144
const persona = AiPersona.create(dataClone);
145+
146+
debugger;
141147
persona.tools = this.flattenedToolStructure(dataClone);
142148

143149
return persona;

spec/system/admin_ai_persona_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
tool_selector = PageObjects::Components::SelectKit.new("#control-tools .select-kit")
2828
tool_selector.expand
2929
tool_selector.select_row_by_value("Read")
30+
tool_selector.select_row_by_value("ListCategories")
3031
tool_selector.collapse
3132

3233
tool_selector = PageObjects::Components::SelectKit.new("#control-forcedTools .select-kit")
3334
tool_selector.expand
35+
tool_selector.select_row_by_value("ListCategories")
3436
tool_selector.select_row_by_value("Read")
3537
tool_selector.collapse
3638

@@ -46,8 +48,10 @@
4648
expect(persona.name).to eq("Test Persona")
4749
expect(persona.description).to eq("I am a test persona")
4850
expect(persona.system_prompt).to eq("You are a helpful bot")
49-
expect(persona.tools).to eq([["Read", { "read_private" => nil }, true]])
5051
expect(persona.forced_tool_count).to eq(1)
52+
53+
expected_tools = [["Read", { "read_private" => nil }, true], ["ListCategories", {}, true]]
54+
expect(persona.tools).to contain_exactly(*expected_tools)
5155
end
5256

5357
it "will not allow deletion or editing of system personas" do

0 commit comments

Comments
 (0)