AuroraScienceHub.Framework.Ai 11.2.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package AuroraScienceHub.Framework.Ai --version 11.2.0
                    
NuGet\Install-Package AuroraScienceHub.Framework.Ai -Version 11.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AuroraScienceHub.Framework.Ai" Version="11.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AuroraScienceHub.Framework.Ai" Version="11.2.0" />
                    
Directory.Packages.props
<PackageReference Include="AuroraScienceHub.Framework.Ai" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AuroraScienceHub.Framework.Ai --version 11.2.0
                    
#r "nuget: AuroraScienceHub.Framework.Ai, 11.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AuroraScienceHub.Framework.Ai@11.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AuroraScienceHub.Framework.Ai&version=11.2.0
                    
Install as a Cake Addin
#tool nuget:?package=AuroraScienceHub.Framework.Ai&version=11.2.0
                    
Install as a Cake Tool

AuroraScienceHub.Framework.Ai

AI integrations built on Microsoft Agent Framework and Microsoft.Extensions.AI: a stateless assistant with optional MCP tools, conversation compaction, and DeepL translation.

Overview

AddAi registers a chat client for an OpenAI-compatible provider, a stateless IAiAssistant on top of it, and an IConversationCompactor that folds older messages of a conversation into a summary. The assistant calls the tools of the configured MCP servers and of any tool provider (IAiToolProvider) a service registers itself.

The package does not try to cover or replace Microsoft Agent Framework. It configures its AIAgent and IChatClient from application settings and adds validation, retries, time budgets, MCP tool discovery, conversation compaction, telemetry, and DeepL translation. The API exposes Agent Framework types such as AIAgent and ChatOptions directly.

Key Features

  • Assistant — IAiAssistant.AskAsync sends the instructions, the summary, the recent history and the question, and calls the tools the model asks for
  • Failures as outcomes — a provider failure is reported in AiResult.Outcome and never thrown. Application errors and cancellation by the caller propagate
  • Time budget — Ai:RequestTimeout limits the whole request, retries and tool rounds included
  • MCP tools — Streamable HTTP servers from the Ai:Mcp section; an unreachable server is left out and retried
  • Per-call options — a caller overrides the model, the answer budget, the reasoning effort, the temperature and top-p for one request with ChatOptions
  • DeepL translation — AddDeepl registers the DeepL client with the shared proxy settings
  • Telemetry — gen_ai.* spans and metrics through OpenTelemetry

Installation

dotnet add package AuroraScienceHub.Framework.Ai

The types are grouped by concern: AuroraScienceHub.Framework.Ai.Assistant (IAiAssistant, AiRequest, AiResult, AiChatMessage), ...Ai.Conversation (IConversationCompactor), ...Ai.Options (AiOptions), ...Ai.Tools (IAiToolProvider), ...Ai.Mcp (the built-in MCP tool provider) and ...Ai.Deepl. The root namespace holds AddAi and AiTelemetry.

Versioning

11.1.0 replaces the IGptClient of the 11.0.x line with the Agent Framework based assistant. Removing the GPT client is a breaking change, and it ships in a minor release on purpose: the core and the bot are the only consumers of the package, and both move to the new client in the same release train, so there is no version of the package that has to serve both. The removal is called out in the changelog. A consumer that needs the GPT client stays on 11.0.x.

Usage

Registration

builder.Services.AddAi(builder.Configuration);

AddAi binds the Ai section, validates it on start, and registers the assistant, the compactor and the MCP tool provider. The services are registered even while Ai:Enabled is false, and the graph is resolvable without a key and a model: the assistant then works with a client that fails only if it is called. Callers check AiOptions.Enabled before they ask.

The options are read once, when the services are created: every change of the AI settings applies on a restart.

The optional configure delegate changes the options after the configuration is bound:

builder.Services.AddAi(builder.Configuration, options => options.MaxRetries = 3);

Configuration

{
  "Ai": {
    "Enabled": true,
    "Provider": "OpenAICompatible",
    "Endpoint": "https://api.deepseek.com",
    "ApiKey": "",
    "Model": "deepseek-chat",
    "RequestTimeout": "00:01:00",
    "MaxRetries": 1,
    "MaxOutputTokens": null,
    "SendLegacyMaxTokens": false,
    "ReasoningEffort": null,
    "Temperature": null,
    "TopP": null,
    "MaxToolCallRounds": 5,
    "McpConnectionTimeout": "00:00:05",
    "McpRetryInterval": "00:01:00",
    "UseProxy": false,
    "Mcp": {
      "core": { "Endpoint": "https://core.example.org/mcp" }
    }
  }
}
  • Endpoint must be an absolute HTTPS address; plain HTTP is accepted only for a loopback address, so the API key never leaves the host unencrypted
  • MaxOutputTokens is an upper bound of the answer, not a target size; null means the limit is not sent and the provider default applies
  • SendLegacyMaxTokens also sends the budget as max_tokens, for providers that ignore max_completion_tokens (DeepSeek); OpenAI rejects max_tokens for its reasoning models, so keep it false there
  • ReasoningEffort is null unless the provider should use it; null leaves ChatOptions.Reasoning unset
  • Temperature and TopP are null unless the provider should use them
  • UseProxy sends the provider and the MCP requests through the proxy of the Proxy section; the proxied requests use clients of their own, so the primary handler the host configures for every client stays in place for the direct ones
  • An MCP server without Endpoint is not used; plain HTTP is accepted for it, as no secret is sent there

Asking a question

var request = new AiRequest(
    Instructions: "You answer questions about space weather.",
    Summary: summary,
    History: messages,
    Question: "What is the Kp index now?");

var result = await assistant.AskAsync(request, cancellationToken);
if (result.IsSuccess)
{
    return result.Text;
}

logger.LogWarning("The assistant did not answer: {Outcome}", result.Outcome);

AiRequest.Options overrides the configured defaults for this call only:

var request = new AiRequest(instructions, summary, messages, question)
{
    Options = new ChatOptions { MaxOutputTokens = 400, Temperature = 0.2f },
};

Tools given in AiRequest.Options.Tools are used together with the tools of the IAiToolProvider services, the tools of the request first. A name used more than once — by the request and a provider, or by two providers — fails the request with AiToolNameConflictException, so one tool never silently shadows another.

The assistant is deliberately not streaming: the answer, its usage and its outcome arrive together, and the caller needs the whole text to store it.

Console sample

The console sample registers the package, sends one question, and prints the answer and token usage. Its appsettings.json contains the DeepSeek connection settings without an API key.

  1. Set the API key:

    export Ai__ApiKey="your-api-key"
    
  2. Run the sample from the repository root:

    dotnet run --project samples/Ai/Ai.Sample.csproj
    
  3. Pass a custom question after -- if needed:

    dotnet run --project samples/Ai/Ai.Sample.csproj -- "What is the Kp index?"
    

The host loads environment variables by default, so other settings can be overridden with variables such as Ai__Model and Ai__Endpoint.

Summarizing a conversation

var summary = await compactor.CompactAsync(
    previousSummary,
    olderMessages,
    new ChatOptions { MaxOutputTokens = 800 },
    cancellationToken);

MCP tools

Tools of the configured servers are loaded on the first request, and the list is kept until the application restarts. A server that cannot be reached is left out and tried again after McpRetryInterval, so the assistant answers without its tools meanwhile. A tool of an MCP server returns its structured result as JSON when the server provides one, so the model sees the fields and not only a formatted text.

Own tools

Register any number of IAiToolProvider implementations; all of them are used:

public sealed class AuthenticatedMcpToolProvider : IAiToolProvider
{
    public Task<IReadOnlyList<AITool>> GetToolsAsync(CancellationToken cancellationToken)
        => /* connect to the server and return its tools */;
}

builder.Services.AddSingleton<IAiToolProvider, AuthenticatedMcpToolProvider>();

Two providers that return a tool with the same name — or a tool of the request that shares a name with a provider tool — fail the request with AiToolNameConflictException, which lists the conflicting names: such a configuration would otherwise silently shadow one of the tools.

DeepL translation

builder.Services.AddDeepl();

var text = await deeplClient.TranslateAsync("Aurora", DeeplLanguage.English, DeeplLanguage.Russian, cancellationToken);
{
  "DeepL": {
    "ApiKey": "",
    "UseProxy": false
  },
  "Proxy": {
    "Address": "http://proxy.example.org:3128",
    "UserName": "",
    "Password": ""
  }
}

Telemetry

AiTelemetry.SourceName is the activity source and the meter of the model calls (gen_ai.* spans and metrics); AiTelemetry.McpSourceName is the one of the MCP SDK. Subscribe both in the OpenTelemetry setup of the host.

License

See LICENSE file in the repository root.

  • AuroraScienceHub.Framework.Http — HTTP utilities, including the proxy handler
  • AuroraScienceHub.Framework.Json — JSON serialization
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.4.0 116 11/19/2026
11.3.0 103 11/14/2026
11.2.0 70 11/13/2026
11.1.1 74 11/8/2026
11.1.0 69 11/5/2026
11.0.1 127 10/19/2026
11.0.1-feature-nuget-truste... 91 10/16/2026
11.0.0 80 10/16/2026
10.1.0 245 8/19/2026
10.0.8 144 8/14/2026
10.0.7 145 8/11/2026
10.0.6 141 8/11/2026
10.0.5 166 4/23/2026
10.0.4 155 4/23/2026
10.0.3 165 2/11/2026
10.0.2 154 1/29/2026
10.0.1 255 12/25/2025
10.0.0 477 12/11/2025
9.0.7 474 11/20/2025
9.0.6 235 11/15/2025
Loading failed