Commit 0c602eb62 for llama.cpp
commit 0c602eb629d974b6aa6642bb83a98a49a2a172c3
Author: Kartik Gulia <kgulia@nvidia.com>
Date: Mon Dec 7 02:26:35 2026 +0530
server : add named tool support for anthropic (#33931)
diff --git a/tools/server/server-chat.cpp b/tools/server/server-chat.cpp
index 385a1bec1..e258cffa7 100644
--- a/tools/server/server-chat.cpp
+++ b/tools/server/server-chat.cpp
@@ -624,7 +624,12 @@ json server_chat_convert_anthropic_to_oai(const json & body) {
std::string type = json_value(tc, "type", std::string());
if (type == "auto") {
oai_body["tool_choice"] = "auto";
- } else if (type == "any" || type == "tool") {
+ } else if (type == "tool") {
+ oai_body["tool_choice"] = {
+ {"type", "function"},
+ {"function", {{"name", tc.at("name")}}},
+ };
+ } else if (type == "any") {
oai_body["tool_choice"] = "required";
}
}