chat : allow undeclared tool calls in LFM2 tool-call grammar (#32164)

* chat : honor OpenAI tool strict flag in LFM2 tool-call grammar


* chat : drop strict, always allow undeclared LFM2 tool calls
This commit is contained in:
Tarek Dakhran authored and GitHub committed 2026-11-14 23:34:18 +01:00
1 parent f08bca8a46
commit 0cc522e45d
4 files changed
+34 -3

No files matched your search

+15
View File
@@ -2214,6 +2214,21 @@ static void test_lfm2_parser(const std::string & template_path, bool detailed_de
.expect(simple_assist_msg("", "", "empty_args", "{}"))
.run();
// undeclared names stay tool calls instead of being forced onto a declared tool
tst.test("<|tool_call_start|>[reseat_sim_card()]<|tool_call_end|>")
.tools({ special_function_tool })
.expect(simple_assist_msg("", "", "reseat_sim_card", "{}"))
.run();
tst.test("<|tool_call_start|>[set_sim_lock(mode='pin', force=True)]<|tool_call_end|>")
.tools({ special_function_tool })
.expect_tool_calls({ { "set_sim_lock", R"({"mode": "pin", "force": true})", "" } })
.run();
tst.test("<|tool_call_start|>[special_function(arg1=1)]<|tool_call_end|>")
.tools({ special_function_tool })
.expect(message_assist_call)
.run();
}
static void test_template_output_peg_parsers(bool detailed_debug) {