Skip to content

AgentGraphReducerAttribute

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

AgentGraphReducerAttribute Class

Declares a deterministic reducer node for fan-in convergence in a named graph workflow. The reducer aggregates branch outputs without incurring LLM cost — it is a pure function, not an agent.

public sealed class AgentGraphReducerAttribute : System.Attribute

Inheritance System.Object 🡒 System.Attribute 🡒 AgentGraphReducerAttribute

Example

[AgentGraphReducer("ResearchPipeline", ReducerMethod = nameof(MergeResults))]
public static class ResearchReducer
{
    public static string MergeResults(IReadOnlyList<string> branchOutputs)
        => string.Join("\n---\n", branchOutputs);
}

Remarks

The ReducerMethod must be a public static method on the decorated class that accepts System.Collections.Generic.IReadOnlyList<> of System.String and returns System.String.

Constructors

AgentGraphReducerAttribute(string) Constructor

Initializes a new AgentGraphReducerAttribute.

public AgentGraphReducerAttribute(string graphName);

Parameters

graphName System.String

The name of the graph this reducer belongs to.

Properties

AgentGraphReducerAttribute.GraphName Property

Gets the graph name this reducer belongs to.

public string GraphName { get; }

Property Value

System.String

AgentGraphReducerAttribute.ReducerMethod Property

Gets or sets the name of the static method on the decorated class that performs the reduction. The method must accept System.Collections.Generic.IReadOnlyList<> of System.String and return System.String.

public string? ReducerMethod { get; set; }

Property Value

System.String

Remarks

If not specified, defaults to "Reduce" by convention. The source generator will look for a public static string Reduce(IReadOnlyList<string>) method on the decorated class.