Fixed answers that quietly skipped your data sources (#968)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-09-14 11:20:57 +02:00
1 parent 828541ce93
commit 6e735523c6
10 files changed
+142 -8

No files matched your search

@@ -240,6 +240,12 @@ public sealed class AIJobService(SettingsManager settingsManager, MessageBus mes
catch (Exception e)
{
logger.LogError(e, "Skipping the RAG process due to an error.");
//
// The answer is about to be created without the data the user expected it to use.
// Without this message, that answer is indistinguishable from one that did use it:
//
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.Source, TB("Your data sources could not be used. This answer was created without them.")));
}
token.ThrowIfCancellationRequested();
@@ -2,6 +2,8 @@ namespace AIStudio.Tools;
public static class IConfidenceExtensions
{
private static readonly ILogger<IConfidence> LOGGER = Program.LOGGER_FACTORY.CreateLogger<IConfidence>();
public static TargetWindow DetermineTargetWindow<T>(this IReadOnlyList<T> items, TargetWindowStrategy strategy, int numMaximumItems = 30) where T : IConfidence
{
switch (strategy)
@@ -53,8 +55,18 @@ public static class IConfidenceExtensions
{
if(!targetWindow.IsValid())
{
var logger = Program.SERVICE_PROVIDER.GetService<ILogger<IConfidence>>()!;
logger.LogWarning("The target window is invalid. Returning 0f as threshold.");
LOGGER.LogWarning("The target window is invalid. Returning 0f as threshold.");
return 0f;
}
//
// Without items there is no threshold to find, and the Min and Max calls below would throw
// on an empty sequence. Every caller checks this today, which is precisely how such a guard
// goes missing once a new caller arrives. It belongs here, next to the calls it protects:
//
if(items.Count == 0)
{
LOGGER.LogWarning("There are no items to determine a confidence threshold for. Returning 0f as threshold.");
return 0f;
}
@@ -91,10 +103,7 @@ public static class IConfidenceExtensions
}
}
else
{
var logger = Program.SERVICE_PROVIDER.GetService<ILogger<IConfidence>>()!;
logger.LogWarning("The confidence values are too close. Returning 0f as threshold.");
}
LOGGER.LogWarning("The confidence values are too close. Returning 0f as threshold.");
return threshold;
}
@@ -70,10 +70,19 @@ public sealed class AugmentationOne : IAugmentationProcess
catch (Exception exception)
{
LOGGER.LogError(exception, "Retrieval context validation failed. Continuing augmentation with all retrieved contexts.");
//
// The user switched this check on. Continuing without it silently would hide
// that the answer rests on unfiltered passages:
//
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.FactCheck, TB("The check of which passages fit your question failed. This answer uses all passages that were found.")));
}
}
else
{
LOGGER.LogWarning("Skipping retrieval context validation because no sufficiently trusted validation agent provider is available. Continuing augmentation with all retrieved contexts.");
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.FactCheck, TB("No provider is trusted enough to check which passages fit your question. This answer uses all passages that were found.")));
}
}
LOGGER.LogInformation($"Starting the augmentation process over {retrievalContexts.Count:###,###,###,###} of {numTotalRetrievalContexts:###,###,###,###} retrieved contexts.");
@@ -50,7 +50,7 @@ public class AgenticSrcSelWithDynHeur : IDataSourceSelectionProcess
}
// Log the selected data sources:
var selectedDataSourceInfo = aiSelectedDataSources.Select(ds => $"[Id={ds.Id}, reason={ds.Reason}, confidence={ds.Confidence}]").Aggregate((a, b) => $"'{a}', '{b}'");
var selectedDataSourceInfo = string.Join(", ", aiSelectedDataSources.Select(ds => $"'[Id={ds.Id}, reason={ds.Reason}, confidence={ds.Confidence}]'"));
LOGGER.LogInformation($"The AI selected the data sources automatically. {aiSelectedDataSources.Count} data source(s) are selected: {selectedDataSourceInfo}.");
//
@@ -106,6 +106,15 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess
{
LOGGER.LogWarning("No data sources are selected. The RAG process is skipped.");
proceedWithRAG = false;
//
// When the user picked the sources, none of them survived the security and
// confidence checks. That is worth saying out loud: the user chose them and
// expects this answer to use them. When the AI picked instead, finding nothing
// suitable for this prompt is a normal outcome and stays in the log.
//
if(!chatThread.DataSourceOptions.AutomaticDataSourceSelection)
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.Source, TB("None of your selected data sources is available for the chosen provider. This answer was created without them.")));
}
else
{