Report prompt injection findings from the embedding pipeline

This commit is contained in:
Thorsten Sommer committed 2026-09-06 15:26:16 +02:00
1 parent 1bf11c0ca7
commit 9875fbc646
2 files changed
+41 -4

No files matched your search

@@ -9,13 +9,12 @@ using AIStudio.Tools.Databases;
using AIStudio.Tools.Databases.IndexStore;
using AIStudio.Tools.Databases.VectorStore;
using AIStudio.Tools.PluginSystem;
using AIStudio.Tools.Security;
namespace AIStudio.Tools.Services;
public sealed partial class DataSourceEmbeddingService(
SettingsManager settingsManager, RustService rustService, DatabaseClientProvider databaseClientProvider,
ILogger<DataSourceEmbeddingService> logger)
: BackgroundService
public sealed partial class DataSourceEmbeddingService(SettingsManager settingsManager, RustService rustService, DatabaseClientProvider databaseClientProvider,
PromptInjectionGuardService guardService, ILogger<DataSourceEmbeddingService> logger) : BackgroundService
{
private const int VECTOR_STORE_OPTIMIZATION_CHUNK_THRESHOLD = 100_000;
@@ -568,6 +567,14 @@ public sealed partial class DataSourceEmbeddingService(
var lastError = inputFiles.LastError;
var failureDetails = inputFiles.Failures.ToList();
//
// Everything the runtime filters out of these files is reported once for the whole data
// source. A run over a few thousand documents which removes something in forty of them
// is one thing that happened to the user, not forty. The scope ends with this method, so
// the report arrives when the run is finished rather than in the middle of it.
//
await using var promptInjectionReportingScope = guardService.BeginAction();
foreach (var file in indexedFiles)
{
token.ThrowIfCancellationRequested();