Skip to content

AgentGraphEdgeAttribute

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

AgentGraphEdgeAttribute Class

Declares a directed edge from the decorated agent to the specified target agent type within a named graph workflow. Apply multiple times for fan-out (multiple outgoing edges from one agent).

public sealed class AgentGraphEdgeAttribute : System.Attribute

Inheritance System.Object 🡒 System.Attribute 🡒 AgentGraphEdgeAttribute

Example

[NeedlrAiAgent(Instructions = "Analyze the request.")]
[AgentGraphEntry("Research")]
[AgentGraphEdge("Research", typeof(WebAgent), Condition = "NeedsWebData")]
[AgentGraphEdge("Research", typeof(SummaryAgent))]
public class AnalyzerAgent { }

Remarks

Edge placement follows the same convention as AgentHandoffsToAttribute: the attribute is placed on the source agent and references the target.

When Condition is set, the edge is conditional. In Deterministic mode, the condition string names a predicate method on the agent class. In LlmChoice mode, the condition string becomes a tool description for LLM-based routing.

Constructors

AgentGraphEdgeAttribute(string, Type) Constructor

Initializes a new AgentGraphEdgeAttribute.

public AgentGraphEdgeAttribute(string graphName, System.Type targetAgentType);

Parameters

graphName System.String

The name of the graph this edge belongs to.

targetAgentType System.Type

The downstream agent type.

Properties

AgentGraphEdgeAttribute.Condition Property

Gets or sets the optional routing condition. Interpretation depends on the graph's GraphRoutingMode. When null, the edge is unconditional.

public string? Condition { get; set; }

Property Value

System.String

AgentGraphEdgeAttribute.GraphName Property

Gets the graph name this edge belongs to.

public string GraphName { get; }

Property Value

System.String

AgentGraphEdgeAttribute.HasNodeRoutingMode Property

Gets whether NodeRoutingMode was explicitly set on this edge. When false, the graph-wide routing mode is used.

public bool HasNodeRoutingMode { get; }

Property Value

System.Boolean

AgentGraphEdgeAttribute.IsRequired Property

Gets or sets whether this edge's target is required for graph success. When true (default), a failure in the target node fails the entire graph. When false, the branch is marked degraded but parallel branches continue.

public bool IsRequired { get; set; }

Property Value

System.Boolean

AgentGraphEdgeAttribute.NodeRoutingMode Property

Gets or sets a per-node routing mode override for the source node of this edge. When set on any edge from a given source node, this overrides the graph-wide RoutingMode for that node's outgoing edges. Only needs to be set on one edge per source node (the generator reads the first non-null value). Use HasNodeRoutingMode to check if a value was explicitly set.

public NexusLabs.Needlr.AgentFramework.GraphRoutingMode NodeRoutingMode { get; set; }

Property Value

GraphRoutingMode

AgentGraphEdgeAttribute.TargetAgentType Property

Gets the downstream agent type.

public System.Type TargetAgentType { get; }

Property Value

System.Type