MODULE 01 · LESSON 1.4
Configure a model and light up AI
Replace the echo response with a configured AI agent.
Lesson 4 of 86 · FabrCore 2.0
Overview
The model configuration name is an application alias. It can point to a different deployment without changing agent code. AgentSession carries the reasoning runtime's session, while FabrCore supplies its history provider. The file-based model store is separate from normal .NET options.
How the model alias is resolved
The instance's Models value is default. The model store looks up that name, reads its provider and model/deployment, and resolves ApiKeyAlias against the credential entries. “default” is your application's alias; it is not the provider's model name. A Cloud Server can supply the same model-store document, so the C# agent does not need a different implementation for that path.
Where reasoning and history live
OnInitialize constructs the AIAgent and AgentSession once for the proxy activation. OnMessage runs the model with the incoming text and turns its output into a FabrCore response. Reusing the session/thread is what makes a follow-up refer to earlier turns. This agent has no request-system tools yet, so it can summarize supplied details but cannot retrieve SR-1042 from a business system.
Configure and call the AI agent
Download the Operations Desk source. The README lists project setup, package prerequisites and local ports.
- Add OperationsAgent.cs to the agents project. For the local-file path, save one provider configuration as OperationsDesk.Server/fabrcore.json and substitute your actual model/deployment and credential. Do not commit the credential file.
- Restart the Host so it loads the new type and model configuration. Use a new handle ai-assistant, AgentType ops-assistant and Models default; leave Plugins empty until module 3.
- Run the console with -- --ai after applying the caller changes shown in lesson 1.3. It must create and chat with ai-assistant, rather than reusing the echo instance's configuration.
using FabrCore.Core;
using FabrCore.Sdk;
using Microsoft.Agents.AI;
[AgentAlias("ops-assistant")]
public sealed class OperationsAgent(
AgentConfiguration config,
IServiceProvider services,
IFabrCoreAgentHost host) : FabrCoreAgentProxy(config, services, host)
{
private AIAgent agent = null!;
private AgentSession session = null!;
public override async Task OnInitialize()
{
var tools = await ResolveConfiguredToolsAsync();
var created = await CreateChatClientAgent(
config.Models ?? "default", "main", tools);
agent = created.Agent;
session = created.Session;
}
public override async Task<AgentMessage> OnMessage(AgentMessage message)
{
var result = await agent.RunAsync(message.Message ?? string.Empty, session);
var response = message.Response();
response.Message = result.Text;
return response;
}
}
{
"ModelConfigurations": [
{
"Name": "default",
"Provider": "OpenAI",
"Model": "gpt-4o",
"ApiKeyAlias": "openai-key",
"TimeoutSeconds": 120,
"MaxOutputTokens": 16384,
"ReasoningEffort": "none",
"ContextWindowTokens": 128000
}
],
"ApiKeys": [
{ "Alias": "openai-key", "Value": "sk-..." }
]
}
{
"ModelConfigurations": [
{
"Name": "default",
"Provider": "Azure",
"Uri": "https://your-resource.openai.azure.com/",
"Model": "gpt-4o",
"ApiKeyAlias": "azure-key"
}
],
"ApiKeys": [
{ "Alias": "azure-key", "Value": "your-key-here" }
]
}
dotnet run --project OperationsDesk.Console -- --ai "SR-1042: the warehouse printer jams after every third page. Summarize the problem in one sentence."
dotnet run --project OperationsDesk.Console -- --ai "How often does it jam?"
For an enrolled Host, the Cloud Server returns the model catalog through GET /fabrcore-cloud/v1/configuration. The response below is the document the Host pulls, not a vendor-specific endpoint for saving an editor form. Store and publish it using your Cloud Server's management implementation.
The Host still needs local CloudServer bootstrap settings, and OperationsAgent.cs must still be deployed. Lesson 13.2 covers enrollment. Keep provider credentials in protected cloud storage and serve them only to the authenticated Host.
- Publish a modelConfigurations entry named default and its matching apiKeys alias for the target cluster/environment.
- Return the effective envelope with a changed configurationVersion/ETag. Wait for the Host to pull that version and inspect its reported status.
- Create ai-assistant using ops-assistant and Models default, then perform the same two-message check below.
{
"schemaVersion": 1,
"configurationVersion": "ops-model-1",
"configuration": {
"modelConfigurations": [
{
"name": "default",
"provider": "OpenAI",
"model": "<your-model>",
"apiKeyAlias": "ops-model-key"
}
],
"apiKeys": [
{
"alias": "ops-model-key",
"value": "<resolved-on-server>"
}
]
}
}
Ask two related questions
- Create a separate instance named ai-assistant using ops-assistant and model alias default. Leave the working assistant echo instance available so a model failure can be isolated from transport.
- Send “SR-1042: the warehouse printer jams after every third page. Summarize the problem in one sentence.” Expect a paraphrase of those facts, not an exact echo. Wording varies by model.
- Send “How often does it jam?” to the same principal, instance and thread. A grounded reply says every third page. Do not create a fresh session for this second message.
The first reply exercises model resolution and inference. The follow-up exercises conversation continuity. Neither result shows access to a real ticket system; the facts came from your prompt.
If the result is different
Check file location, provider spelling, endpoint and ApiKeyAlias. Never commit real keys. Do not assume user-secrets overrides entries in a separately loaded fabrcore.json without wiring a supported model-store path.
Go deeper
Explore the related documentation.