Skip to content

NeedlrAiAgentAttribute

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

NeedlrAiAgentAttribute Class

Marks a class as a declared agent type for Needlr's Agent Framework integration. Apply this attribute to a class to enable compile-time registration via the source generator and CreateAgent<TAgent>() lookup.

public sealed class NeedlrAiAgentAttribute : System.Attribute

Inheritance System.Object 🡒 System.Attribute 🡒 NeedlrAiAgentAttribute

Example

[NeedlrAiAgent(
    Instructions = "You are a helpful customer support agent. Answer questions about orders.",
    Description = "Customer support agent for order inquiries")]
[AgentHandoffsTo(typeof(BillingAgent), "Escalate billing or payment questions to the billing agent")]
public class CustomerSupportAgent
{
}

// In your composition root:
var agentFactory = syringe.BuildAgentFactory();
var agent = agentFactory.CreateAgent<CustomerSupportAgent>();

Remarks

When the NexusLabs.Needlr.AgentFramework.Generators package is referenced, a [ModuleInitializer] is emitted that automatically registers the agent type with AgentFrameworkGeneratedBootstrap. UsingAgentFramework() then discovers and registers these types without any explicit Add*FromGenerated() calls.

Properties

NeedlrAiAgentAttribute.Description Property

Gets or sets a human-readable description of this agent's purpose.

public string? Description { get; set; }

Property Value

System.String

NeedlrAiAgentAttribute.FunctionGroups Property

Gets or sets named function groups (registered via AgentFunctionGroupAttribute) whose types are wired as tools for this agent.

public string[]? FunctionGroups { get; set; }

Property Value

System.String[]

NeedlrAiAgentAttribute.FunctionTypes Property

Gets or sets the function types whose AgentFunctionAttribute-tagged methods are wired as tools for this agent. When null and FunctionGroups is also null, all registered function types are used.

public System.Type[]? FunctionTypes { get; set; }

Property Value

System.Type[]

NeedlrAiAgentAttribute.Instructions Property

Gets or sets the system prompt instructions for this agent.

public string? Instructions { get; set; }

Property Value

System.String