diff --git a/src/Purrse.Api/Services/ChatService.cs b/src/Purrse.Api/Services/ChatService.cs index 3d3d685..0a94c0c 100644 --- a/src/Purrse.Api/Services/ChatService.cs +++ b/src/Purrse.Api/Services/ChatService.cs @@ -251,10 +251,10 @@ public class ChatService : IChatService var rawContent = response?.Message?.Content ?? "I'm sorry, I couldn't process that request."; // If the model responded without calling any tools on the first attempt - // AND there are no prior tool results in the conversation, it likely - // fabricated data. Nudge it to use tools. Skip the nudge when prior - // tool results exist — the model may be referencing earlier data. - if (toolResults.Count == 0 && i == 0 && !hasExistingToolResults) + // AND there are no prior tool results AND no page context data, it + // likely fabricated data. Nudge it to use tools. Skip when prior tool + // results or page context exist — the model has real data to reference. + if (toolResults.Count == 0 && i == 0 && !hasExistingToolResults && string.IsNullOrEmpty(request.PageContext)) { _logger.LogWarning("Model responded without calling tools on first attempt, retrying with nudge"); ollamaMessages.Add(new OllamaToolMessage