Skip to content

AgentSequenceMemberAttribute

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

AgentSequenceMemberAttribute Class

Marks an agent class as a member of a named sequential pipeline, specifying its position. The source generator reads these declarations to emit a strongly-typed Create{PipelineName}SequentialWorkflow() extension method on IWorkflowFactory.

public sealed class AgentSequenceMemberAttribute : System.Attribute

Inheritance System.Object 🡒 System.Attribute 🡒 AgentSequenceMemberAttribute

Example

[NeedlrAiAgent(Instructions = "Extract key facts from the user's input.")]
[AgentSequenceMember("ContentPipeline", order: 0)]
public class ExtractorAgent { }

[NeedlrAiAgent(Instructions = "Summarize extracted facts into a concise paragraph.")]
[AgentSequenceMember("ContentPipeline", order: 1)]
public class SummarizerAgent { }

[NeedlrAiAgent(Instructions = "Format the summary as a structured JSON report.")]
[AgentSequenceMember("ContentPipeline", order: 2)]
public class FormatterAgent { }

// The source generator emits:
//   workflowFactory.CreateContentPipelineSequentialWorkflow()

Remarks

Apply multiple instances of this attribute on different agent classes with the same pipelineName to declare the full sequence. Agents are executed in ascending order — output from each agent is passed as input to the next.

Constructors

AgentSequenceMemberAttribute(string, int) Constructor

Marks an agent class as a member of a named sequential pipeline, specifying its position. The source generator reads these declarations to emit a strongly-typed Create{PipelineName}SequentialWorkflow() extension method on IWorkflowFactory.

public AgentSequenceMemberAttribute(string pipelineName, int order);

Parameters

pipelineName System.String

order System.Int32

Example

[NeedlrAiAgent(Instructions = "Extract key facts from the user's input.")]
[AgentSequenceMember("ContentPipeline", order: 0)]
public class ExtractorAgent { }

[NeedlrAiAgent(Instructions = "Summarize extracted facts into a concise paragraph.")]
[AgentSequenceMember("ContentPipeline", order: 1)]
public class SummarizerAgent { }

[NeedlrAiAgent(Instructions = "Format the summary as a structured JSON report.")]
[AgentSequenceMember("ContentPipeline", order: 2)]
public class FormatterAgent { }

// The source generator emits:
//   workflowFactory.CreateContentPipelineSequentialWorkflow()

Remarks

Apply multiple instances of this attribute on different agent classes with the same pipelineName to declare the full sequence. Agents are executed in ascending order — output from each agent is passed as input to the next.

Properties

AgentSequenceMemberAttribute.Order Property

The zero-based position of this agent within the pipeline sequence.

public int Order { get; }

Property Value

System.Int32

AgentSequenceMemberAttribute.PipelineName Property

The name of the sequential pipeline this agent belongs to.

public string PipelineName { get; }

Property Value

System.String