From 367b7e2feae0e0296ba8cdc108edef035b2428bb Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Fri, 14 Nov 2025 15:46:07 +0100 Subject: [PATCH] fix: handle tool errors Signed-off-by: Ettore Di Giacinto --- backend/cpp/llama-cpp/grpc-server.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/cpp/llama-cpp/grpc-server.cpp b/backend/cpp/llama-cpp/grpc-server.cpp index 72ed1b09b568..a26d995a458c 100644 --- a/backend/cpp/llama-cpp/grpc-server.cpp +++ b/backend/cpp/llama-cpp/grpc-server.cpp @@ -621,6 +621,11 @@ class BackendServiceImpl final : public backend::Backend::Service { content_val = msg.content(); } + // If content is an object (e.g., from tool call failures), convert to string + if (content_val.is_object()) { + content_val = content_val.dump(); + } + // If content is a string and this is the last user message with images/audio, combine them if (content_val.is_string() && is_last_user_msg && has_images_or_audio) { json content_array = json::array(); @@ -1046,6 +1051,11 @@ class BackendServiceImpl final : public backend::Backend::Service { content_val = msg.content(); } + // If content is an object (e.g., from tool call failures), convert to string + if (content_val.is_object()) { + content_val = content_val.dump(); + } + // If content is a string and this is the last user message with images/audio, combine them if (content_val.is_string() && is_last_user_msg && has_images_or_audio) { json content_array = json::array();