LogicBuilder.App.AI.Utils
1.0.1
Prefix Reserved
dotnet add package LogicBuilder.App.AI.Utils --version 1.0.1
NuGet\Install-Package LogicBuilder.App.AI.Utils -Version 1.0.1
<PackageReference Include="LogicBuilder.App.AI.Utils" Version="1.0.1" />
<PackageVersion Include="LogicBuilder.App.AI.Utils" Version="1.0.1" />
<PackageReference Include="LogicBuilder.App.AI.Utils" />
paket add LogicBuilder.App.AI.Utils --version 1.0.1
#r "nuget: LogicBuilder.App.AI.Utils, 1.0.1"
#:package LogicBuilder.App.AI.Utils@1.0.1
#addin nuget:?package=LogicBuilder.App.AI.Utils&version=1.0.1
#tool nuget:?package=LogicBuilder.App.AI.Utils&version=1.0.1
LogicBuilder.App.AI.Utils
LogicBuilder.App.AI.Utils is a .NET library for declaratively building, running, and consuming Microsoft Agent Foundry AI agents, rather than hand-coding the Azure AI Projects / Microsoft.Agents.AI SDK calls directly.
It is intended for applications that need to:
- Define AI agents (name, model, instructions, and tools such as MCP servers or web search) declaratively — e.g. from configuration, a database, or a UI — and materialize those definitions into runnable
AIAgentinstances. - Create those agents from application configuration (e.g. an
AZURE_AI_FOUNDRY_PROJECT_ENDPOINTsetting) without directly wiring up Azure credentials or theAIProjectClient. - Drive conversations with an
AIAgent(session/thread initialization, single-shot responses, and streaming responses) using a simple, serializable session/thread identifier that callers can persist between requests. - Present citation/source references returned by an agent as inline Markdown links within the response text, rather than raw annotation metadata.
Key Concepts
The library is organized around a few cooperating areas:
1. Declarative agent definition (Parameters → Builders)
Two parallel object hierarchies connected by an AutoMapper profile:
Parameters (
LogicBuilder.App.AI.Utils.Parameters) — plain data objects describing what an agent should look like:IAgentParameters/AgentParameters— agent name, model, instructions, and a collection of tool parameters.IAgentToolParameters— base interface for tool definitions, implemented by:McpToolParameters— describes an MCP (Model Context Protocol) tool/server.WebSearchToolParameters— describes a web search tool.
Builders (
LogicBuilder.App.AI.Utils.Builders) — objects that know how to construct the corresponding Azure AI Foundry / Agents SDK artifacts:IAgentBuilder/AgentBuilder— wraps anAIProjectClientplus agent metadata and tool builders, and exposesBuild()to produce a liveAIAgent.IAgentToolBuilderimplementations (e.g.McpToolBuilder,WebSearchToolBuilder) — each know how to build the corresponding tool definition consumed by the agent.
Mapping (
LogicBuilder.App.AI.Utils.Mapping) —ParametersToBuilderMappingProfileis an AutoMapperProfilethat maps the parameter hierarchy onto the builder hierarchy (including polymorphic mapping of tool parameter types to their matching tool builder types). AnAIProjectClientis supplied via the AutoMapperResolutionContext.Items(seeMappingConstants.AI_PROJECT_CLIENT_CONTEXT) so it can be injected into the constructedAgentBuilder.
2. Configuration-driven agent creation
IAgentCreator/AgentCreator— reads the Foundry project endpoint fromIConfiguration(AZURE_AI_FOUNDRY_PROJECT_ENDPOINT), constructs anAIProjectClientusingDefaultAzureCredential, and uses AutoMapper to turn anAgentParametersinstance directly into a ready-to-useAIAgentviaAgentBuilder.Build(). This removes the need for calling code to manage Azure credentials orAIProjectClientconstruction itself.
3. Conversation/session handling
IAgentHandler/AgentHandler— a thin, serialization-friendly wrapper aroundAIAgentconversation APIs:InitializeSession(AIAgent)— creates a newChatClientAgentSessionfor the agent and returns it serialized as a JSON string, suitable for persisting as a "thread ID" between requests.SendMessageToAgent(...)— deserializes a previously-saved thread ID, sends a user message to the agent, and returns anAgentStreamResultcontaining the (citation-formatted) response text along with the updated, re-serialized thread ID.SendMessageToAgentWithStreamingResponse(...)— same as above, but streams response chunks as they arrive (viaIAsyncEnumerable<AgentStreamResult>), yielding a final chunk with the updated serialized thread state once streaming completes.AgentStreamResult(LogicBuilder.App.AI.Utils.Structures) — a simple result type distinguishing streamed content chunks (FromChunk) from the final updated thread state (FromState).
4. Inline citation formatting
IInlineCitationFormatter/InlineCitationFormatter— takes agent response text plus itsCitationAnnotationmetadata (character-span based source references) and rewrites the text so each citation span is replaced with an inline Markdown link (e.g.[contoso-tents-catalog.pdf](https://.../contoso-tents-catalog.pdf)), using the citation's title/URL to derive a friendly link label. This lets UIs render citations as normal Markdown without needing to understand the underlying annotation model.
Typical Usage
Defining and building an agent directly via AutoMapper
- Construct an
AIProjectClient(via Azure Identity credentials) for your Foundry project. - Build up an
IAgentParametersobject graph describing the agent (name, model, instructions, and tools). - Use AutoMapper (configured with
ParametersToBuilderMappingProfile) to map the parameters into anIAgentBuilder/AgentBuilder, passing theAIProjectClientthrough the mapping context. - Call
Build()on the resultingAgentBuilderto obtain a ready-to-useAIAgent.
IAgentParameters agentParameters = new AgentParameters
(
"AgentName",
"gpt-5.2",
"You are a helpful AI assistant...",
[
new McpToolParameters("GreetingTool", "https://example.com/mcp", true),
new WebSearchToolParameters()
]
);
AgentBuilder agentBuilder = mapper.Map<AgentBuilder>
(
agentParameters,
opts => opts.Items[MappingConstants.AI_PROJECT_CLIENT_CONTEXT] = projectClient
);
AIAgent agent = agentBuilder.Build();
Creating an agent from configuration with AgentCreator
// AZURE_AI_FOUNDRY_PROJECT_ENDPOINT must be present in IConfiguration.
IAgentCreator agentCreator = new AgentCreator(configuration, mapper);
AgentParameters agentParameters = new
(
"AgentName",
"gpt-5.2",
"You are a helpful AI assistant...",
[ new WebSearchToolParameters() ]
);
AIAgent agent = agentCreator.CreateAgent(agentParameters);
Running a conversation with AgentHandler
IAgentHandler agentHandler = new AgentHandler(new InlineCitationFormatter());
// Start a new conversation and persist the returned thread ID (e.g. in a cookie, DB row, etc.).
string threadId = await agentHandler.InitializeSession(agent);
// Send a message using the persisted thread ID; receive citation-formatted text plus the updated thread ID.
AgentStreamResult result = await agentHandler.SendMessageToAgent(agent, threadId, "What tents do you offer?");
string responseText = result.ContentChunk; threadId = result.UpdatedThreadId;
// Or stream the response as it is generated.
await foreach (AgentStreamResult chunk in agentHandler.SendMessageToAgentWithStreamingResponse(agent, threadId, "Tell me more."))
{
if (chunk.ContentChunk is not null)
{ // Append chunk.ContentChunk to the UI as it streams in.
}
else if (chunk.UpdatedThreadId is not null)
{ threadId = chunk.UpdatedThreadId;
}
}
Solution Layout
| Project | Purpose |
|---|---|
LogicBuilder.App.AI.Utils |
Core library (parameters, builders, AutoMapper profile, agent creation, conversation handling, and inline citation formatting) — targets .NET Standard 2.0. |
LogicBuilder.App.AI.Utils.Tests |
xUnit/Moq test suite validating parameter → builder mapping, configuration-driven agent creation, conversation/session handling, and inline citation formatting — targets .NET 10. |
Dependencies
- AutoMapper — maps parameter objects to builder objects.
- Microsoft.Agents.AI.Foundry — provides the
AIProjectClient/AIAgenttypes used to construct and run agents in Microsoft Agent Foundry. - Azure.Identity — supplies
DefaultAzureCredentialused byAgentCreatorto authenticate theAIProjectClient. - Microsoft.Extensions.Configuration — used by
AgentCreatorto read the Foundry project endpoint from application configuration.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- AutoMapper (>= 16.2.0)
- LogicBuilder.App.Utils (>= 1.0.8)
- LogicBuilder.RulesDirector (>= 2.0.6)
- Microsoft.Agents.AI.Foundry (>= 1.22.0-preview.260918.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 |
|---|---|---|
| 1.0.1 | 84 | 9/23/2026 |
First release.