From 7f2f996cd62ad89493e8a6c284d8f17d55dfe74d Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Fri, 2 May 2025 14:16:39 -0700 Subject: [PATCH] server/routes: catch when JSON tool was used --- server/routes.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/routes.go b/server/routes.go index f09b632dd..c40ab211c 100644 --- a/server/routes.go +++ b/server/routes.go @@ -1553,12 +1553,13 @@ func (s *Server) ChatHandler(c *gin.Context) { toolCallIndex++ } res.Message.Content = "" - sb.Reset() ch <- res // Only way to have multiple calls is to have [] which is derived or provided - if templateToolToken == "" { + // This case occurs when the tool call is a json block - do not allow tool calls again + if templateToolToken == "" || (templateToolToken != "" && !strings.HasPrefix(sb.String(), templateToolToken)) { checkToolCall = false } + sb.Reset() return } }