From d44eb95c6724fe629aaeb9ca3b046ca776c58044 Mon Sep 17 00:00:00 2001 From: ochafik Date: Tue, 4 Feb 2025 04:18:49 +0000 Subject: [PATCH] tool-call: ensure we don't return content when there are tool calls / warn --- common/chat.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/chat.cpp b/common/chat.cpp index b6e1a87a8..c134ae568 100644 --- a/common/chat.cpp +++ b/common/chat.cpp @@ -134,6 +134,14 @@ static common_chat_msg parse_json_tool_calls( it = match.suffix().first; result.tool_calls.push_back({name, arguments.is_string() ? arguments.get() : arguments.dump(), /* id= */ ""}); } + + if (!result.tool_calls.empty()) { + if (!string_trim(result.content).empty()) { + LOG_WRN("Content found with tool calls: %s", result.content.c_str()); + } + result.content = ""; + result.role = "user"; + } return result; }