From 2aaf29acb5caf3f1fdc50cd48542c94df801752f Mon Sep 17 00:00:00 2001 From: Eva Ho Date: Mon, 10 Nov 2025 19:05:00 -0500 Subject: [PATCH 1/4] app/ui: do not send to prevent errors with cloud provider --- app/ui/ui.go | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/app/ui/ui.go b/app/ui/ui.go index fce58895..4cacc3c2 100644 --- a/app/ui/ui.go +++ b/app/ui/ui.go @@ -782,6 +782,25 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error { var thinkValue any if req.Think != nil { + // Validate that the model supports thinking if requested + thinkRequested := false + switch v := req.Think.(type) { + case bool: + thinkRequested = v + case string: + thinkRequested = v != "" && v != "none" + } + + if thinkRequested && !think { + errorEvent := responses.ErrorEvent{ + EventName: "error", + Error: fmt.Sprintf("Model %q does not support thinking/reasoning", req.Model), + Code: "model_capability_error", + } + json.NewEncoder(w).Encode(errorEvent) + flusher.Flush() + return nil + } thinkValue = req.Think } else { thinkValue = think @@ -866,6 +885,9 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error { return err } + // Debug: Log what we're sending + s.log().Debug("sending chat request", "model", chatReq.Model, "think", chatReq.Think, "num_messages", len(chatReq.Messages)) + err = c.Chat(ctx, chatReq, func(res api.ChatResponse) error { if loading { // Remove the loading indicator on first token @@ -1794,13 +1816,14 @@ func (s *Server) buildChatRequest(chat *store.Chat, model string, think any, ava var thinkValue *api.ThinkValue if think != nil { + // Only set Think if it's actually requesting thinking if boolValue, ok := think.(bool); ok { - thinkValue = &api.ThinkValue{ - Value: boolValue, + if boolValue { + thinkValue = &api.ThinkValue{Value: boolValue} } } else if stringValue, ok := think.(string); ok { - thinkValue = &api.ThinkValue{ - Value: stringValue, + if stringValue != "" && stringValue != "none" { + thinkValue = &api.ThinkValue{Value: stringValue} } } } From 6a818b8a094c2f53775d877f38f7f855346c77a7 Mon Sep 17 00:00:00 2001 From: Eva Ho Date: Mon, 10 Nov 2025 19:08:42 -0500 Subject: [PATCH 2/4] clean up --- app/ui/ui.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/ui/ui.go b/app/ui/ui.go index 4cacc3c2..631066e9 100644 --- a/app/ui/ui.go +++ b/app/ui/ui.go @@ -885,9 +885,6 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error { return err } - // Debug: Log what we're sending - s.log().Debug("sending chat request", "model", chatReq.Model, "think", chatReq.Think, "num_messages", len(chatReq.Messages)) - err = c.Chat(ctx, chatReq, func(res api.ChatResponse) error { if loading { // Remove the loading indicator on first token From 9d615cdaa0f1eb96491b672c9e48f999338dffa5 Mon Sep 17 00:00:00 2001 From: Eva Ho Date: Mon, 10 Nov 2025 20:13:50 -0500 Subject: [PATCH 3/4] fix test --- app/ui/ui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ui/ui.go b/app/ui/ui.go index 631066e9..a05ecf0f 100644 --- a/app/ui/ui.go +++ b/app/ui/ui.go @@ -790,7 +790,7 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error { case string: thinkRequested = v != "" && v != "none" } - + if thinkRequested && !think { errorEvent := responses.ErrorEvent{ EventName: "error", From 2a9b61f099b5f5307b3af463bd6b1464941260fd Mon Sep 17 00:00:00 2001 From: Eva Ho Date: Tue, 11 Nov 2025 08:58:55 -0500 Subject: [PATCH 4/4] address comment --- app/ui/app/src/api.ts | 9 ++++++++- app/ui/ui.go | 19 ------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/ui/app/src/api.ts b/app/ui/app/src/api.ts index c8b2e116..4158bafc 100644 --- a/app/ui/app/src/api.ts +++ b/app/ui/app/src/api.ts @@ -205,6 +205,13 @@ export async function* sendMessage( data: uint8ArrayToBase64(att.data), })); + // Only send think parameter when actually requesting thinking + // Don't send false as it causes issues with some providers + const shouldSendThink = + think !== undefined && + ((typeof think === "boolean" && think) || + (typeof think === "string" && think !== "")); + const response = await fetch(`${API_BASE}/api/v1/chat/${chatId}`, { method: "POST", headers: { @@ -222,7 +229,7 @@ export async function* sendMessage( web_search: webSearch ?? false, file_tools: fileTools ?? false, ...(forceUpdate !== undefined ? { forceUpdate } : {}), - ...(think !== undefined ? { think } : {}), + ...(shouldSendThink ? { think } : {}), }), ), signal, diff --git a/app/ui/ui.go b/app/ui/ui.go index a05ecf0f..1d0e2579 100644 --- a/app/ui/ui.go +++ b/app/ui/ui.go @@ -782,25 +782,6 @@ func (s *Server) chat(w http.ResponseWriter, r *http.Request) error { var thinkValue any if req.Think != nil { - // Validate that the model supports thinking if requested - thinkRequested := false - switch v := req.Think.(type) { - case bool: - thinkRequested = v - case string: - thinkRequested = v != "" && v != "none" - } - - if thinkRequested && !think { - errorEvent := responses.ErrorEvent{ - EventName: "error", - Error: fmt.Sprintf("Model %q does not support thinking/reasoning", req.Model), - Code: "model_capability_error", - } - json.NewEncoder(w).Encode(errorEvent) - flusher.Flush() - return nil - } thinkValue = req.Think } else { thinkValue = think