Skip to content

Commit 2c07ce7

Browse files
committed
Only use MCP handler with non-empty string
1 parent e7efd7c commit 2c07ce7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

common/common.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,8 +1839,8 @@ std::string common_chat_apply_template(
18391839
toolcall::handler::ptr handler,
18401840
toolcall::sampling_updater * update_sparams)
18411841
{
1842-
const auto & tmpl_selected =
1843-
handler != nullptr && tmpl.template_tool_use ? *tmpl.template_tool_use : *tmpl.template_default;
1842+
bool use_tool_template = (use_jinja && handler != nullptr) && tmpl.template_tool_use;
1843+
const auto & tmpl_selected = use_tool_template ? *tmpl.template_tool_use : *tmpl.template_default;
18441844

18451845
if (use_jinja) {
18461846
common_chat_inputs inputs;

common/toolcall/handler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ std::shared_ptr<toolcall::handler> toolcall::create_handler(const toolcall::para
2121
bool has_uri = std::holds_alternative<std::string>(tools);
2222
if (has_uri) {
2323
auto tools_str = std::get<std::string>(tools);
24-
result.reset(new toolcall::handler(std::make_unique<toolcall::mcp_impl>(tools_str, choice)));
24+
if (! tools_str.empty()) {
25+
result.reset(new toolcall::handler(std::make_unique<toolcall::mcp_impl>(tools_str, choice)));
26+
}
2527

2628
} else {
2729
auto tools_ptr = std::get<toolcall::json_ptr>(tools);

0 commit comments

Comments
 (0)