Skip to content

AgentFrameworkSyringe

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

AgentFrameworkSyringe Class

Fluent builder for configuring the Microsoft Agent Framework with Needlr function discovery.

public sealed record AgentFrameworkSyringe : System.IEquatable<NexusLabs.Needlr.AgentFramework.AgentFrameworkSyringe>

Inheritance System.Object 🡒 AgentFrameworkSyringe

Implements System.IEquatable<AgentFrameworkSyringe>

Example

// Obtained from SyringeAgentFrameworkExtensions.UsingAgentFramework()
AgentFrameworkSyringe 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 Needlr 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.