AgentFrameworkBuilder
NexusLabs.Foundry.MicrosoftAgentFramework¶
NexusLabs.Foundry.MicrosoftAgentFramework¶
AgentFrameworkBuilder Class¶
Fluent builder for configuring the Microsoft Agent Framework with Foundry function discovery.
public sealed record AgentFrameworkBuilder : System.IEquatable<NexusLabs.Foundry.MicrosoftAgentFramework.AgentFrameworkBuilder>
Inheritance System.Object 🡒 AgentFrameworkBuilder
Implements System.IEquatable<AgentFrameworkBuilder>
Example¶
// Obtained from SyringeAgentFrameworkExtensions.UsingAgentFramework()
AgentFrameworkBuilder syringe = app.Services.UsingAgentFramework();
// Register function types and build the factory
IAgentFactory factory = syringe
.AddAgentFunctionsFromGenerated(GeneratedAgentFunctions.AllFunctionTypes)
.BuildAgentFactory();
// Create agents from the factory
var supportAgent = factory.CreateAgent<CustomerSupportAgent>();
Remarks¶
When the Foundry source generator is active (the common case), this class uses pre-built
IAIFunctionProvider instances registered by the generated [ModuleInitializer].
No reflection is required in that path.
When the source generator is not used, this class falls back to reflection to discover
methods decorated with AgentFunctionAttribute. That path carries
[RequiresDynamicCode] and is not NativeAOT-compatible.