Skip to content

Commit d44eb95

Browse files
author
ochafik
committed
tool-call: ensure we don't return content when there are tool calls / warn
1 parent 812544a commit d44eb95

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

common/chat.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ static common_chat_msg parse_json_tool_calls(
134134
it = match.suffix().first;
135135
result.tool_calls.push_back({name, arguments.is_string() ? arguments.get<std::string>() : arguments.dump(), /* id= */ ""});
136136
}
137+
138+
if (!result.tool_calls.empty()) {
139+
if (!string_trim(result.content).empty()) {
140+
LOG_WRN("Content found with tool calls: %s", result.content.c_str());
141+
}
142+
result.content = "";
143+
result.role = "user";
144+
}
137145
return result;
138146
}
139147

0 commit comments

Comments
 (0)