Private
Public Access
1
0

Skip tool-use nudge when page context provides data

The nudge forced the AI to call a tool even when the answer was
already in the page context (e.g. Sarku transactions visible on the
Transactions page). This caused the model to pick an unrelated tool.
Now the nudge also checks for page context — if the current page has
data attached, the model is allowed to answer from it directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-11 20:23:10 -05:00
parent 8421d244f2
commit 8e342045eb
+4 -4
View File
@@ -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