Skip to content

Commit 03e9f4b

Browse files
authored
fix: handle tool errors (#7271)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 7129409 commit 03e9f4b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

backend/cpp/llama-cpp/grpc-server.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ class BackendServiceImpl final : public backend::Backend::Service {
621621
content_val = msg.content();
622622
}
623623

624+
// If content is an object (e.g., from tool call failures), convert to string
625+
if (content_val.is_object()) {
626+
content_val = content_val.dump();
627+
}
628+
624629
// If content is a string and this is the last user message with images/audio, combine them
625630
if (content_val.is_string() && is_last_user_msg && has_images_or_audio) {
626631
json content_array = json::array();
@@ -1046,6 +1051,11 @@ class BackendServiceImpl final : public backend::Backend::Service {
10461051
content_val = msg.content();
10471052
}
10481053

1054+
// If content is an object (e.g., from tool call failures), convert to string
1055+
if (content_val.is_object()) {
1056+
content_val = content_val.dump();
1057+
}
1058+
10491059
// If content is a string and this is the last user message with images/audio, combine them
10501060
if (content_val.is_string() && is_last_user_msg && has_images_or_audio) {
10511061
json content_array = json::array();

0 commit comments

Comments
 (0)