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

@@ -63,7 +63,7 @@ public record ChatTemplate(
/// <remarks>
/// Null means the template says nothing, so the chat starts with the data source defaults from
/// the app settings. Anything else is the template's own answer, and it carries more than a
/// list of sources: whether data sources are used at all, whether an agent picks them, and
/// list of sources: whether data sources are used at all, whether an AI operation picks them, and
/// whether the retrieved data is validated.
/// </remarks>
public DataSourceOptions? DataSourceOptions { get; set; }
@@ -202,7 +202,7 @@ public record ChatTemplate(
/// </summary>
/// <remarks>
/// The two sides are not equally expressive: a launcher can only ever say "these sources, picked
/// by hand", while a chat template carries the whole options and can also say "let an agent pick
/// by hand", while a chat template carries the whole options and can also say "let an AI operation pick
/// them for each message". Mixing them field by field would produce something neither of them
/// asked for, so the template wins as a whole.
/// </remarks>
@@ -6,7 +6,7 @@ using AIStudio.Assistants.SlideBuilder;
using AIStudio.Assistants.TextSummarizer;
using AIStudio.Assistants.EMail;
using AIStudio.Provider;
using AIStudio.Agents.AssistantAudit;
using AIStudio.AIOperations.PluginAudit;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.PluginSystem;
@@ -400,11 +400,11 @@ public static class ConfigurationSelectDataFactory
yield return new(theme.Name, theme);
}
public static IEnumerable<ConfigurationSelectData<AssistantAuditLevel>> GetAssistantAuditLevelsData()
public static IEnumerable<ConfigurationSelectData<PluginAuditLevel>> GetAssistantAuditLevelsData()
{
foreach (var level in Enum.GetValues<AssistantAuditLevel>())
foreach (var level in Enum.GetValues<PluginAuditLevel>())
{
if (level == AssistantAuditLevel.UNKNOWN)
if (level == PluginAuditLevel.UNKNOWN)
continue;
yield return new(level.Name, level);
@@ -48,7 +48,7 @@ public sealed class Data
/// </summary>
/// <remarks>
/// A list of its own rather than a part of DataSources: classic RAG, Semantic Search and the
/// agents read DataSources, and none of them is meant to see a mailbox. It also keeps the
/// AI operations read DataSources, and none of them is meant to see a mailbox. It also keeps the
/// settings readable for older versions of AI Studio, so the settings version stays the same.
/// An older version skips a property it does not know, but would fail to read the whole file
/// over a data source type it does not know. It drops the list, though, the next time it stores
@@ -193,7 +193,7 @@ public sealed class Data
public DataSWOTAnalysis SWOTAnalysis { get; set; } = new();
public DataTextContentCleaner TextContentCleaner { get; set; } = new();
public DataTextContentCleaner TextContentCleaner { get; set; } = new(x => x.TextContentCleaner);
public DataAgentDataSourceSelection AgentDataSourceSelection { get; set; } = new(x => x.AgentDataSourceSelection);
@@ -1,5 +1,7 @@
using System.Linq.Expressions;
using AIStudio.Provider;
namespace AIStudio.Settings.DataModel;
public sealed class DataAgentDataSourceSelection(Expression<Func<Data, DataAgentDataSourceSelection>>? configSelection = null)
@@ -20,4 +22,12 @@ public sealed class DataAgentDataSourceSelection(Expression<Func<Data, DataAgent
/// Preselect a data source selection provider?
/// </summary>
public string PreselectedAgentProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedAgentProvider, string.Empty);
/// <summary>
/// The minimum confidence level of the provider which selects the data sources.
/// </summary>
/// <remarks>
/// It applies only while PreselectAgentOptions is on, and then to every provider which selects them, the fallbacks included.
/// </remarks>
public ConfidenceLevel MinimumProviderConfidence { get; set; } = ManagedConfiguration.Register(configSelection, n => n.MinimumProviderConfidence, ConfidenceLevel.NONE);
}
@@ -1,5 +1,7 @@
using System.Linq.Expressions;
using AIStudio.Provider;
namespace AIStudio.Settings.DataModel;
public sealed class DataAgentRetrievalContextValidation(Expression<Func<Data, DataAgentRetrievalContextValidation>>? configSelection = null)
@@ -12,7 +14,7 @@ public sealed class DataAgentRetrievalContextValidation(Expression<Func<Data, Da
}
/// <summary>
/// Enable the retrieval context validation agent?
/// Enable the retrieval context validation?
/// </summary>
public bool EnableRetrievalContextValidation { get; set; } = ManagedConfiguration.Register(configSelection, n => n.EnableRetrievalContextValidation, false);
@@ -26,6 +28,14 @@ public sealed class DataAgentRetrievalContextValidation(Expression<Func<Data, Da
/// </summary>
public string PreselectedAgentProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedAgentProvider, string.Empty);
/// <summary>
/// The minimum confidence level of the provider which validates the retrieval contexts.
/// </summary>
/// <remarks>
/// It applies only while PreselectAgentOptions is on, and then to every provider which validates them, the fallbacks included.
/// </remarks>
public ConfidenceLevel MinimumProviderConfidence { get; set; } = ManagedConfiguration.Register(configSelection, n => n.MinimumProviderConfidence, ConfidenceLevel.NONE);
/// <summary>
/// Configure how many parallel validations to run.
/// </summary>
@@ -1,5 +1,7 @@
using System.Linq.Expressions;
using AIStudio.Agents.AssistantAudit;
using AIStudio.AIOperations.PluginAudit;
using AIStudio.Provider;
namespace AIStudio.Settings.DataModel;
@@ -26,10 +28,18 @@ public sealed class DataAssistantPluginAudit(Expression<Func<Data, DataAssistant
/// </summary>
public string PreselectedAgentProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedAgentProvider, string.Empty);
/// <summary>
/// The minimum confidence level of the provider which audits the plugins.
/// </summary>
/// <remarks>
/// It applies to every provider which audits a plugin, the fallbacks included.
/// </remarks>
public ConfidenceLevel MinimumProviderConfidence { get; set; } = ManagedConfiguration.Register(configSelection, n => n.MinimumProviderConfidence, ConfidenceLevel.NONE);
/// <summary>
/// The minimum audit level assistant plugins should meet.
/// </summary>
public AssistantAuditLevel MinimumLevel { get; set; } = ManagedConfiguration.Register(configSelection, n => n.MinimumLevel, AssistantAuditLevel.CAUTION);
public PluginAuditLevel MinimumLevel { get; set; } = ManagedConfiguration.Register(configSelection, n => n.MinimumLevel, PluginAuditLevel.CAUTION);
/// <summary>
/// Should activation be blocked when the audit result is below the minimum level?
@@ -20,7 +20,7 @@ public class DataLegalCheck
public bool PreselectWebContentReader { get; set; }
/// <summary>
/// Preselect the content cleaner agent?
/// Preselect the text content cleaner?
/// </summary>
public bool PreselectContentCleanerAgent { get; set; }
@@ -20,7 +20,7 @@ public sealed class DataSWOTAnalysis
public bool PreselectWebContentReader { get; set; }
/// <summary>
/// Preselect the content cleaner agent?
/// Preselect the text content cleaner?
/// </summary>
public bool PreselectContentCleanerAgent { get; set; }
@@ -10,7 +10,7 @@ namespace AIStudio.Settings.DataModel;
/// </summary>
/// <remarks>
/// Mailboxes are kept in Data.Mailboxes rather than in DataSources, which is why this is no
/// IDataSource: classic RAG, Semantic Search and the agents never see a mailbox. Only the mail
/// IDataSource: classic RAG, Semantic Search and the AI operations never see a mailbox. Only the mail
/// tools read from one.
/// </remarks>
public record struct DataSourceMailbox: IIndexedDataSource, ISecretId
@@ -7,14 +7,14 @@ public enum DataSourceRetrievalMode
{
/// <summary>
/// The model searches the data sources itself, through the tool semantic_search, whenever a
/// question calls for it. No agent takes part: the chat model picks the data sources and
/// question calls for it. No AI operation takes part: the chat model picks the data sources and
/// judges what it found.
/// </summary>
SEMANTIC_SEARCH,
/// <summary>
/// AI Studio searches the data sources with every message, before the model answers. This is
/// the classic RAG process, with its agents for selecting data sources and for validating what
/// the classic RAG process, with its AI operations for selecting data sources and for validating what
/// was found.
/// </summary>
EVERY_MESSAGE,
@@ -1,14 +1,33 @@
using System.Linq.Expressions;
using AIStudio.Provider;
namespace AIStudio.Settings.DataModel;
public sealed class DataTextContentCleaner
public sealed class DataTextContentCleaner(Expression<Func<Data, DataTextContentCleaner>>? configSelection = null)
{
/// <summary>
/// The default constructor for the JSON deserializer.
/// </summary>
public DataTextContentCleaner() : this(null)
{
}
/// <summary>
/// Preselect any text content cleaner options?
/// </summary>
public bool PreselectAgentOptions { get; set; }
public bool PreselectAgentOptions { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectAgentOptions, false);
/// <summary>
/// Preselect a text content cleaner provider?
/// </summary>
public string PreselectedAgentProvider { get; set; } = string.Empty;
public string PreselectedAgentProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedAgentProvider, string.Empty);
/// <summary>
/// The minimum confidence level of the provider which cleans the text content.
/// </summary>
/// <remarks>
/// It applies only while PreselectAgentOptions is on, and then to every provider which cleans it, the fallbacks included.
/// </remarks>
public ConfidenceLevel MinimumProviderConfidence { get; set; } = ManagedConfiguration.Register(configSelection, n => n.MinimumProviderConfidence, ConfidenceLevel.NONE);
}
@@ -22,7 +22,7 @@ public sealed class DataTextSummarizer
public bool PreselectWebContentReader { get; set; }
/// <summary>
/// Preselect the content cleaner agent?
/// Preselect the text content cleaner?
/// </summary>
public bool PreselectContentCleanerAgent { get; set; }
@@ -30,7 +30,7 @@ public sealed class DataTranslation
public bool PreselectWebContentReader { get; set; }
/// <summary>
/// Preselect the content cleaner agent?
/// Preselect the text content cleaner?
/// </summary>
public bool PreselectContentCleanerAgent { get; set; }
@@ -10,7 +10,7 @@ public static class DataSourceOrderExtensions
/// </summary>
/// <remarks>
/// The same data sources always come in the same order, however the settings list them, the
/// checks return them, or an agent selects them. Semantic Search offers them this way, because
/// checks return them, or an AI operation selects them. Semantic Search offers them this way, because
/// the providers cache a request from its beginning, and the tools are part of that beginning,
/// see IToolImplementation.ResolveFunctionAsync. DataSourceRequirements names the first of
/// several equally strict data sources this way, so that both ways of searching name the same.
@@ -7,7 +7,7 @@ using AIStudio.Tools.RAG;
namespace AIStudio.Settings;
/// <summary>
/// The common interface for the data sources in DataSources, which classic RAG, Semantic Search and the agents read.
/// The common interface for the data sources in DataSources, which classic RAG, Semantic Search and the AI operations read.
/// </summary>
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type_discriminator")]
[JsonDerivedType(typeof(DataSourceLocalDirectory), nameof(DataSourceType.LOCAL_DIRECTORY))]
@@ -8,7 +8,7 @@ namespace AIStudio.Settings;
/// </summary>
/// <remarks>
/// Not every data source is an IDataSource. Those are the ones in DataSources, which classic RAG,
/// Semantic Search and the agents read. A data source kept in a list of its own is never handed to
/// Semantic Search and the AI operations read. A data source kept in a list of its own is never handed to
/// them, and the compiler sees to that, because it implements only this interface or
/// IIndexedDataSource.
/// </remarks>
@@ -464,13 +464,16 @@ public sealed class SettingsManager
public void InjectSpellchecking(Dictionary<string, object?> attributes) => attributes["spellcheck"] = this.ConfigurationData.App.EnableSpellchecking ? "true" : "false";
/// <summary>
/// The global minimum confidence level; NONE when neither the user nor the organization enforces one.
/// </summary>
public ConfidenceLevel GlobalMinimumConfidenceLevel => this.ConfigurationData.Confidence is { EnforceGlobalMinimumConfidence: true, GlobalMinimumConfidence: not ConfidenceLevel.NONE and not ConfidenceLevel.UNKNOWN }
? this.ConfigurationData.Confidence.GlobalMinimumConfidence
: ConfidenceLevel.NONE;
public ConfidenceLevel GetMinimumConfidenceLevel(Tools.Components component)
{
var minimumLevel = ConfidenceLevel.NONE;
var enforceGlobalMinimumConfidence = this.ConfigurationData.Confidence is { EnforceGlobalMinimumConfidence: true, GlobalMinimumConfidence: not ConfidenceLevel.NONE and not ConfidenceLevel.UNKNOWN };
if (enforceGlobalMinimumConfidence)
minimumLevel = this.ConfigurationData.Confidence.GlobalMinimumConfidence;
var minimumLevel = this.GlobalMinimumConfidenceLevel;
var componentMinimumLevel = component.MinimumConfidence(this);
if (componentMinimumLevel > minimumLevel)
minimumLevel = componentMinimumLevel;
@@ -612,6 +615,18 @@ public sealed class SettingsManager
return this.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.ConfigurationData.App.PreselectedProvider && this.IsProviderUsable(x.UsedLLMProvider, minimumLevel)) ?? Provider.NONE;
}
/// <summary>
/// The ID of the provider which serves as the app-wide default.
/// </summary>
/// <remarks>
/// With exactly one configured provider, that one is the default, whatever the settings name, as in
/// GetPreselectedProvider. Neither a prohibition nor the confidence level is checked here: whoever uses
/// the provider checks them, e.g., AIOperationProviderChoice. The ID is empty when no default is set.
/// </remarks>
public string AppDefaultProviderId => this.ConfigurationData.Providers.Count == 1
? this.ConfigurationData.Providers[0].Id
: this.ConfigurationData.App.PreselectedProvider;
public Provider GetChatProviderForLoadedChat(string? chatProviderId = null)
{
var minimumLevel = this.GetMinimumConfidenceLevel(Tools.Components.CHAT);