XBag.AI.Prompts.Agents
0.1.0-preview.1
dotnet add package XBag.AI.Prompts.Agents --version 0.1.0-preview.1
NuGet\Install-Package XBag.AI.Prompts.Agents -Version 0.1.0-preview.1
<PackageReference Include="XBag.AI.Prompts.Agents" Version="0.1.0-preview.1" />
<PackageVersion Include="XBag.AI.Prompts.Agents" Version="0.1.0-preview.1" />
<PackageReference Include="XBag.AI.Prompts.Agents" />
paket add XBag.AI.Prompts.Agents --version 0.1.0-preview.1
#r "nuget: XBag.AI.Prompts.Agents, 0.1.0-preview.1"
#:package XBag.AI.Prompts.Agents@0.1.0-preview.1
#addin nuget:?package=XBag.AI.Prompts.Agents&version=0.1.0-preview.1&prerelease
#tool nuget:?package=XBag.AI.Prompts.Agents&version=0.1.0-preview.1&prerelease
XBag.AI.Prompts.Agents
Microsoft Agent Framework glue for
XBag.AI.Prompts: PromptInstructionsProvider, an AIContextProvider that renders a prompt
template into the agent's instructions at the start of every run, with variables taken from that run (run options,
session state, request messages).
Part of the XBag family of .NET packages by Murat Ay, the author of XBag, a .NET process-orchestration and decisioning platform. Community package, not affiliated with Microsoft.
Pipeline slot: agent layer, ChatClientAgentOptions.AIContextProviders, once per RUN.
ChatClientAgent appends the rendered text to its own ChatOptions.Instructions ("\n" between them)
and sends it on every model call of the run, tool-loop iterations included.
Install
dotnet add package XBag.AI.Prompts.Agents --prerelease
Example
Per-run instructions from the run options (this is
AgentInstructionsTests.cs, run in CI on the
real ChatClientAgent, buffered and streaming):
PromptTemplate template = PromptTemplate.Parse("""
Kullanıcı: {{kullanıcı}}. Şehir: {{şehir}}.
{{#if vip}}
VIP müşteri, önce ona cevap ver.
{{/if}}
""");
AIAgent agent = model.AsAIAgent(new ChatClientAgentOptions
{
ChatOptions = new() { Instructions = "Sen Anadolu Kargo'nun asistanısın." },
AIContextProviders =
[
new PromptInstructionsProvider(template, run => new PromptArguments
{
["kullanıcı"] = "Murat",
["şehir"] = run.RunOptions?.AdditionalProperties?["şehir"],
["vip"] = run.RunOptions?.AdditionalProperties?.ContainsKey("vip") == true,
}),
],
});
await agent.RunAsync("Şube kaçta açılıyor?", options: new AgentRunOptions
{
AdditionalProperties = new() { ["şehir"] = "İstanbul", ["vip"] = true },
});
Assert.Equal(
"Sen Anadolu Kargo'nun asistanısın.\nKullanıcı: Murat. Şehir: İstanbul.\nVIP müşteri, önce ona cevap ver.",
model.Requests[0].Instructions);
API
| Type / member | What it is |
|---|---|
new PromptInstructionsProvider(template, arguments?) |
Fixed arguments for every run |
new PromptInstructionsProvider(template, Func<AgentRunContext, PromptArguments?>) |
Per-run arguments: run.RunOptions, run.Session (its StateBag), run.RequestMessages, run.Agent |
StateKeys |
Empty: nothing is stored in the session, so several providers can sit on one agent |
Errors surface before the model is called: a missing variable throws PromptTemplateException, and a template with
message blocks throws InvalidOperationException (instructions are text; render chat templates with
RenderMessagesAsync and pass the messages to RunAsync).
What this is not
- Not a message injector. It sets instructions only. Few-shot messages from a provider would be appended after the
user's message by
AIContextProvider's merge, so they are not offered. - No prompt catalog or DI registration yet: see the roadmap.
If Microsoft ships prompt templates
See XBag.AI.Prompts. The provider seam
(AIContextProvider, stable in 1.24.0) would stay the same; only the template behind it would change.
Versions
Depends on Microsoft.Agents.AI.Abstractions 1.24.0 and XBag.AI.Prompts. Tested on .NET 8 and .NET 10.
Status: 0.1.0-preview.1, the API may change before 1.0.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
-
net10.0
- Microsoft.Agents.AI.Abstractions (>= 1.24.0)
- XBag.AI.Prompts (>= 0.1.0-preview.1)
-
net8.0
- Microsoft.Agents.AI.Abstractions (>= 1.24.0)
- XBag.AI.Prompts (>= 0.1.0-preview.1)
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 |
|---|---|---|
| 0.1.0-preview.1 | 85 | 10/11/2026 |