Moved the background agents to AI operations (#1215)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-21 19:47:10 +01:00
1 parent 8a4a26503b
commit c50a93cd17
139 files changed
+4069 -2340

No files matched your search

@@ -67,7 +67,7 @@ public sealed class ClassicRagOutboundDataRestrictionTests : ToolRegistryTestBas
public void BothWaysOfSearchingRestrictTheChatAlike(IDataSource[] dataSources, int[] passageCounts, OutboundDataRestriction organizationMinimum)
{
//
// Semantic Search offers the data sources in a fixed order, while the selection agent of the
// Semantic Search offers the data sources in a fixed order, while the data source selection of the
// classic process may return them in any order. Both have to name the same data source.
//
// AsEnumerable() keeps Reverse() a reversed copy: from C# 14 on, Reverse() on an array
@@ -61,7 +61,7 @@ public sealed class ClassicRagUnreachableTests
{
var unreachable = Checked([INTRANET, WIKI]).GetUnreachableOfTheChat(new DataSourceOptions { AutomaticDataSourceSelection = true });
Assert.That(unreachable, Is.EqualTo(new[] { INTRANET, WIKI }), "The selection agent might have picked any of them.");
Assert.That(unreachable, Is.EqualTo(new[] { INTRANET, WIKI }), "The data source selection might have picked any of them.");
}
[Test]
@@ -1,51 +0,0 @@
using AIStudio.Settings.DataModel;
using AIStudio.Tools.Services;
namespace AIStudio.Tests.Tools;
/// <summary>
/// Checks which agents count as seeing the data of the data sources.
/// </summary>
/// <remarks>
/// Every provider which sees the data must be trusted enough for every data source it sees. That
/// cuts both ways: leaving out an agent which does run would send data to a provider trusted too
/// little, while counting an agent which does not run holds back data sources for no reason. The
/// classic RAG process runs its agents; Semantic Search runs none, since the chat model picks the
/// data sources and judges the passages itself.
/// </remarks>
[TestFixture]
public sealed class DataSourceParticipatingAgentsTests
{
[Test]
public void SemanticSearchRunsNoAgent()
{
var agents = DataSourceService.GetParticipatingAgents(Options(automaticSelection: true, automaticValidation: true), DataSourceRetrievalMode.SEMANTIC_SEARCH, retrievalContextValidationEnabled: true);
Assert.That(agents, Is.Empty, "The chat provider alone sees the data, so its trust alone decides which data sources it may search.");
}
[Test]
public void TheClassicRAGProcessCountsTheAgentsItRuns()
{
var agents = DataSourceService.GetParticipatingAgents(Options(automaticSelection: true, automaticValidation: true), DataSourceRetrievalMode.EVERY_MESSAGE, retrievalContextValidationEnabled: true);
Assert.That(agents.Select(agent => agent.Component), Is.EqualTo(new[] { AIStudio.Tools.Components.AGENT_DATA_SOURCE_SELECTION, AIStudio.Tools.Components.AGENT_RETRIEVAL_CONTEXT_VALIDATION }));
}
[Test]
public void TheClassicRAGProcessCountsNoAgentItDoesNotRun()
{
using (Assert.EnterMultipleScope())
{
Assert.That(DataSourceService.GetParticipatingAgents(Options(automaticSelection: false, automaticValidation: false), DataSourceRetrievalMode.EVERY_MESSAGE, retrievalContextValidationEnabled: true), Is.Empty);
Assert.That(DataSourceService.GetParticipatingAgents(Options(automaticSelection: false, automaticValidation: true), DataSourceRetrievalMode.EVERY_MESSAGE, retrievalContextValidationEnabled: false), Is.Empty, "The validation of this chat is on, but the settings switch it off everywhere.");
}
}
private static DataSourceOptions Options(bool automaticSelection, bool automaticValidation) => new()
{
DisableDataSources = false,
AutomaticDataSourceSelection = automaticSelection,
AutomaticValidation = automaticValidation,
};
}
@@ -0,0 +1,51 @@
using AIStudio.Settings.DataModel;
using AIStudio.Tools.Services;
namespace AIStudio.Tests.Tools;
/// <summary>
/// Checks which AI operations count as seeing the data of the data sources.
/// </summary>
/// <remarks>
/// Every provider which sees the data must be trusted enough for every data source it sees. That
/// cuts both ways: leaving out an operation which does run would send data to a provider trusted too
/// little, while counting an operation which does not run holds back data sources for no reason. The
/// classic RAG process runs its AI operations; Semantic Search runs none, since the chat model picks the
/// data sources and judges the passages itself.
/// </remarks>
[TestFixture]
public sealed class DataSourceParticipatingOperationsTests
{
[Test]
public void SemanticSearchRunsNoOperation()
{
var operations = DataSourceService.GetParticipatingOperations(Options(automaticSelection: true, automaticValidation: true), DataSourceRetrievalMode.SEMANTIC_SEARCH, retrievalContextValidationEnabled: true);
Assert.That(operations, Is.Empty, "The chat provider alone sees the data, so its trust alone decides which data sources it may search.");
}
[Test]
public void TheClassicRAGProcessCountsTheOperationsItRuns()
{
var operations = DataSourceService.GetParticipatingOperations(Options(automaticSelection: true, automaticValidation: true), DataSourceRetrievalMode.EVERY_MESSAGE, retrievalContextValidationEnabled: true);
Assert.That(operations.Select(operation => operation.Component), Is.EqualTo(new[] { AIStudio.Tools.Components.AGENT_DATA_SOURCE_SELECTION, AIStudio.Tools.Components.AGENT_RETRIEVAL_CONTEXT_VALIDATION }));
}
[Test]
public void TheClassicRAGProcessCountsNoOperationItDoesNotRun()
{
using (Assert.EnterMultipleScope())
{
Assert.That(DataSourceService.GetParticipatingOperations(Options(automaticSelection: false, automaticValidation: false), DataSourceRetrievalMode.EVERY_MESSAGE, retrievalContextValidationEnabled: true), Is.Empty);
Assert.That(DataSourceService.GetParticipatingOperations(Options(automaticSelection: false, automaticValidation: true), DataSourceRetrievalMode.EVERY_MESSAGE, retrievalContextValidationEnabled: false), Is.Empty, "The validation of this chat is on, but the settings switch it off everywhere.");
}
}
private static DataSourceOptions Options(bool automaticSelection, bool automaticValidation) => new()
{
DisableDataSources = false,
AutomaticDataSourceSelection = automaticSelection,
AutomaticValidation = automaticValidation,
};
}
@@ -55,7 +55,7 @@ public sealed class DataSourceRequirementsTests
using (Assert.EnterMultipleScope())
{
Assert.That(DataSourceRequirements.Of([HANDBOOK, ARCHIVE], [1, 1], OutboundDataRestriction.UNRESTRICTED).OutboundData, Is.EqualTo(expected));
Assert.That(DataSourceRequirements.Of([ARCHIVE, HANDBOOK], [1, 1], OutboundDataRestriction.UNRESTRICTED).OutboundData, Is.EqualTo(expected), "An agent may select the data sources in another order.");
Assert.That(DataSourceRequirements.Of([ARCHIVE, HANDBOOK], [1, 1], OutboundDataRestriction.UNRESTRICTED).OutboundData, Is.EqualTo(expected), "An AI operation may select the data sources in another order.");
}
}
@@ -191,7 +191,7 @@ public sealed class EmbeddingChangeImpactTests
using (Assert.EnterMultipleScope())
{
Assert.That(EditKeepingTheProvider(embeddingProvider, stored, stored with { Name = "Another name" }), Is.False, "The name is how the data source is offered, not how it was read.");
Assert.That(EditKeepingTheProvider(embeddingProvider, stored, stored with { Description = "Another description" }), Is.False, "The description is there for the agent which picks data sources.");
Assert.That(EditKeepingTheProvider(embeddingProvider, stored, stored with { Description = "Another description" }), Is.False, "The description is there for the AI operation which picks data sources.");
Assert.That(EditKeepingTheProvider(embeddingProvider, stored, stored with { MaxMatches = 42 }), Is.False, "How many matches an answer may use is decided per query.");
Assert.That(EditKeepingTheProvider(embeddingProvider, stored, stored with { ConfidenceLevel = ConfidenceLevel.HIGH }), Is.False, "The confidence level is enforced live on every request and changes no vector.");
}
+1 -1
View File
@@ -22,7 +22,7 @@ public sealed class ModelAnswerJsonTests
""";
/// <summary>
/// A data source selection as the agent is asked to write it.
/// A data source selection as the AI operation is asked to write it.
/// </summary>
private const string SELECTION = """
[
@@ -321,7 +321,7 @@ public sealed class SearchMailsToolTests : ToolRegistryTestBase
[Test]
public void SemanticSearchNeverSeesAMailbox()
{
Assert.That(typeof(IDataSource).IsAssignableFrom(typeof(DataSourceMailbox)), Is.False, "Semantic Search, classic RAG, and the agents take their data sources from DataSources, which holds only IDataSource. A mailbox has its own rules and tools.");
Assert.That(typeof(IDataSource).IsAssignableFrom(typeof(DataSourceMailbox)), Is.False, "Semantic Search, classic RAG, and the AI operations take their data sources from DataSources, which holds only IDataSource. A mailbox has its own rules and tools.");
}
// Stating its definition and reading its arguments needs none of the services the tool searches with: