Skip to content

SyringeExtensionsForAgentFramework

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

SyringeExtensionsForAgentFramework Class

Extension methods for NexusLabs.Needlr.Injection.ConfiguredSyringe that enable registering Microsoft Agent Framework infrastructure (namely IAgentFactory) as part of the Needlr build pipeline.

public static class SyringeExtensionsForAgentFramework

Inheritance System.Object 🡒 SyringeExtensionsForAgentFramework

Remarks

These helpers defer service registration using the Syringe post-plugin registration callback so that function discovery and registration are completed before the agent factory is added.

When the Needlr source generator is active, the generated [ModuleInitializer] registers an IAIFunctionProvider that is used instead of reflection. This makes the integration NativeAOT-compatible without any code changes.

When the source generator is not used, the integration falls back to reflection-based Microsoft.Extensions.AI.AIFunction schema generation, which requires dynamic code.

Methods

SyringeExtensionsForAgentFramework.UsingAgentFramework(this ConfiguredSyringe) Method

Registers an IAgentFactory built via a AgentFrameworkSyringe instance.

public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingAgentFramework(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe);

Parameters

syringe NexusLabs.Needlr.Injection.ConfiguredSyringe

The NexusLabs.Needlr.Injection.ConfiguredSyringe to augment with the registration.

Returns

NexusLabs.Needlr.Injection.ConfiguredSyringe
A new NexusLabs.Needlr.Injection.ConfiguredSyringe instance containing the registration.

SyringeExtensionsForAgentFramework.UsingAgentFramework(this ConfiguredSyringe, Func<AgentFrameworkSyringe,AgentFrameworkSyringe>) Method

Registers an IAgentFactory built via a configurable AgentFrameworkSyringe instance.

public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingAgentFramework(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe, System.Func<NexusLabs.Needlr.AgentFramework.AgentFrameworkSyringe,NexusLabs.Needlr.AgentFramework.AgentFrameworkSyringe> configure);

Parameters

syringe NexusLabs.Needlr.Injection.ConfiguredSyringe

The NexusLabs.Needlr.Injection.ConfiguredSyringe to augment with the registration.

configure System.Func<AgentFrameworkSyringe,AgentFrameworkSyringe>

A delegate that receives a pre-initialized AgentFrameworkSyringe (with its NexusLabs.Needlr.AgentFramework.AgentFrameworkSyringe.ServiceProvider set) and returns the configured instance used to build the agent factory.

Returns

NexusLabs.Needlr.Injection.ConfiguredSyringe
A new NexusLabs.Needlr.Injection.ConfiguredSyringe instance containing the registration.

SyringeExtensionsForAgentFramework.UsingAgentFramework(this ConfiguredSyringe, Func<AgentFrameworkSyringe>) Method

Registers an IAgentFactory built via an AgentFrameworkSyringe created by the supplied delegate.

public static NexusLabs.Needlr.Injection.ConfiguredSyringe UsingAgentFramework(this NexusLabs.Needlr.Injection.ConfiguredSyringe syringe, System.Func<NexusLabs.Needlr.AgentFramework.AgentFrameworkSyringe> configure);

Parameters

syringe NexusLabs.Needlr.Injection.ConfiguredSyringe

The NexusLabs.Needlr.Injection.ConfiguredSyringe to augment with the registration.

configure System.Func<AgentFrameworkSyringe>

A factory that creates a fully-configured AgentFrameworkSyringe used to build the agent factory. Useful when configuration does not need the service provider.

Returns

NexusLabs.Needlr.Injection.ConfiguredSyringe
A new NexusLabs.Needlr.Injection.ConfiguredSyringe instance containing the registration.