AuroraScienceHub.Framework.Ai
11.1.0
Prefix Reserved
See the version list below for details.
dotnet add package AuroraScienceHub.Framework.Ai --version 11.1.0
NuGet\Install-Package AuroraScienceHub.Framework.Ai -Version 11.1.0
<PackageReference Include="AuroraScienceHub.Framework.Ai" Version="11.1.0" />
<PackageVersion Include="AuroraScienceHub.Framework.Ai" Version="11.1.0" />
<PackageReference Include="AuroraScienceHub.Framework.Ai" />
paket add AuroraScienceHub.Framework.Ai --version 11.1.0
#r "nuget: AuroraScienceHub.Framework.Ai, 11.1.0"
#:package AuroraScienceHub.Framework.Ai@11.1.0
#addin nuget:?package=AuroraScienceHub.Framework.Ai&version=11.1.0
#tool nuget:?package=AuroraScienceHub.Framework.Ai&version=11.1.0
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.AskAsyncsends 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.Outcomeand never thrown. Application errors and cancellation by the caller propagate - Time budget —
Ai:RequestTimeoutlimits the whole request, retries and tool rounds included - MCP tools — Streamable HTTP servers from the
Ai:Mcpsection; 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 —
AddDeeplregisters 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" }
}
}
}
Endpointmust be an absolute HTTPS address; plain HTTP is accepted only for a loopback address, so the API key never leaves the host unencryptedMaxOutputTokensis an upper bound of the answer, not a target size;nullmeans the limit is not sent and the provider default appliesSendLegacyMaxTokensalso sends the budget asmax_tokens, for providers that ignoremax_completion_tokens(DeepSeek); OpenAI rejectsmax_tokensfor its reasoning models, so keep itfalsethereReasoningEffortisnullunless the provider should use it;nullleavesChatOptions.ReasoningunsetTemperatureandTopParenullunless the provider should use themUseProxysends the provider and the MCP requests through the proxy of theProxysection; 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
Endpointis 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.
Set the API key:
export Ai__ApiKey="your-api-key"Run the sample from the repository root:
dotnet run --project samples/Ai/Ai.Sample.csprojPass 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.
Related Packages
AuroraScienceHub.Framework.Http— HTTP utilities, including the proxy handlerAuroraScienceHub.Framework.Json— JSON serialization
| Product | Versions 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. |
-
net10.0
- AuroraScienceHub.Framework.Http (>= 11.1.0)
- AuroraScienceHub.Framework.Json (>= 11.1.0)
- AuroraScienceHub.Framework.Utilities (>= 11.1.0)
- DeepL.net (>= 1.22.1)
- Microsoft.Agents.AI (>= 1.25.0)
- Microsoft.Extensions.AI (>= 10.11.0)
- Microsoft.Extensions.AI.OpenAI (>= 10.11.0)
- Microsoft.Extensions.Caching.Abstractions (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Configuration (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Configuration.Abstractions (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Configuration.Binder (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.DependencyInjection (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Hosting.Abstractions (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Http (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Http.Resilience (>= 10.11.0)
- Microsoft.Extensions.Logging (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Logging.Abstractions (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Options (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 11.0.0-rc.2.26504.105)
- ModelContextProtocol.Core (>= 2.2.0)
- OpenAI (>= 2.14.0)
-
net11.0
- AuroraScienceHub.Framework.Http (>= 11.1.0)
- AuroraScienceHub.Framework.Json (>= 11.1.0)
- AuroraScienceHub.Framework.Utilities (>= 11.1.0)
- DeepL.net (>= 1.22.1)
- Microsoft.Agents.AI (>= 1.25.0)
- Microsoft.Extensions.AI (>= 10.11.0)
- Microsoft.Extensions.AI.OpenAI (>= 10.11.0)
- Microsoft.Extensions.Configuration (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Configuration.Binder (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.DependencyInjection (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Http (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Http.Resilience (>= 10.11.0)
- Microsoft.Extensions.Logging (>= 11.0.0-rc.2.26504.105)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 11.0.0-rc.2.26504.105)
- ModelContextProtocol.Core (>= 2.2.0)
- OpenAI (>= 2.14.0)
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 |