< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Analyzers.MafDiagnosticDescriptors
Assembly: NexusLabs.Needlr.AgentFramework.Analyzers
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Analyzers/MafDiagnosticDescriptors.cs
Line coverage
100%
Covered lines: 132
Uncovered lines: 0
Coverable lines: 132
Total lines: 202
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Analyzers/MafDiagnosticDescriptors.cs

#LineLine coverage
 1using Microsoft.CodeAnalysis;
 2
 3namespace NexusLabs.Needlr.AgentFramework.Analyzers;
 4
 5/// <summary>
 6/// Contains diagnostic descriptors for all Needlr Agent Framework analyzers.
 7/// </summary>
 8public static class MafDiagnosticDescriptors
 9{
 10    private const string Category = "NexusLabs.Needlr.AgentFramework";
 11    private const string HelpLinkBase = "https://github.com/nexus-labs/needlr/blob/main/docs/analyzers/";
 12
 13    /// <summary>
 14    /// NDLRMAF001: <c>[AgentHandoffsTo(typeof(X))]</c> target type X is not decorated with <c>[NeedlrAiAgent]</c>.
 15    /// </summary>
 116    public static readonly DiagnosticDescriptor HandoffsToTargetNotNeedlrAgent = new(
 117        id: MafDiagnosticIds.HandoffsToTargetNotNeedlrAgent,
 118        title: "[AgentHandoffsTo] target type is not a declared agent",
 119        messageFormat: "'{0}' is referenced as a handoff target but is not decorated with [NeedlrAiAgent]. Handoff targe
 120        category: Category,
 121        defaultSeverity: DiagnosticSeverity.Error,
 122        isEnabledByDefault: true,
 123        description: "Types used as handoff targets in [AgentHandoffsTo] must also be decorated with [NeedlrAiAgent] so 
 124        helpLinkUri: HelpLinkBase + "NDLRMAF001.md");
 25
 26    /// <summary>
 27    /// NDLRMAF002: <c>[AgentGroupChatMember("g")]</c> group "g" has fewer than two members.
 28    /// </summary>
 129    public static readonly DiagnosticDescriptor GroupChatTooFewMembers = new(
 130        id: MafDiagnosticIds.GroupChatTooFewMembers,
 131        title: "Group chat has fewer than two members",
 132        messageFormat: "Group chat '{0}' has only {1} member(s) in this compilation. A group chat requires at least two 
 133        category: Category,
 134        defaultSeverity: DiagnosticSeverity.Error,
 135        isEnabledByDefault: true,
 136        description: "IWorkflowFactory.CreateGroupChatWorkflow() throws at runtime when fewer than two agents are regist
 137        helpLinkUri: HelpLinkBase + "NDLRMAF002.md",
 138        customTags: WellKnownDiagnosticTags.CompilationEnd);
 39
 40    /// <summary>
 41    /// NDLRMAF003: A class has <c>[AgentHandoffsTo]</c> but is not decorated with <c>[NeedlrAiAgent]</c>.
 42    /// </summary>
 143    public static readonly DiagnosticDescriptor HandoffsToSourceNotNeedlrAgent = new(
 144        id: MafDiagnosticIds.HandoffsToSourceNotNeedlrAgent,
 145        title: "[AgentHandoffsTo] source class is not a declared agent",
 146        messageFormat: "'{0}' has [AgentHandoffsTo] but is not decorated with [NeedlrAiAgent]. The source agent of a han
 147        category: Category,
 148        defaultSeverity: DiagnosticSeverity.Warning,
 149        isEnabledByDefault: true,
 150        description: "The class that carries [AgentHandoffsTo] is the initial agent of a handoff workflow and must also 
 151        helpLinkUri: HelpLinkBase + "NDLRMAF003.md");
 52
 53    /// <summary>
 54    /// NDLRMAF004: A cyclic handoff chain was detected.
 55    /// </summary>
 156    public static readonly DiagnosticDescriptor CyclicHandoffChain = new(
 157        id: MafDiagnosticIds.CyclicHandoffChain,
 158        title: "Cyclic handoff chain detected",
 159        messageFormat: "'{0}' participates in a cyclic handoff chain: {1}. This may cause infinite routing loops at runt
 160        category: Category,
 161        defaultSeverity: DiagnosticSeverity.Warning,
 162        isEnabledByDefault: true,
 163        description: "A handoff cycle exists where an agent can eventually hand off back to itself. While MAF may handle
 164        helpLinkUri: HelpLinkBase + "NDLRMAF004.md",
 165        customTags: WellKnownDiagnosticTags.CompilationEnd);
 66
 67    /// <summary>
 68    /// NDLRMAF005: An agent declares a FunctionGroups entry with no matching [AgentFunctionGroup] class.
 69    /// </summary>
 170    public static readonly DiagnosticDescriptor UnresolvedFunctionGroupReference = new(
 171        id: MafDiagnosticIds.UnresolvedFunctionGroupReference,
 172        title: "FunctionGroups references an unregistered group name",
 173        messageFormat: "'{0}' declares FunctionGroups entry '{1}' but no class decorated with [AgentFunctionGroup(\"{1}\
 174        category: Category,
 175        defaultSeverity: DiagnosticSeverity.Warning,
 176        isEnabledByDefault: true,
 177        description: "When an agent declares FunctionGroups = new[] { \"name\" }, a class with [AgentFunctionGroup(\"nam
 178        helpLinkUri: HelpLinkBase + "NDLRMAF005.md",
 179        customTags: WellKnownDiagnosticTags.CompilationEnd);
 80
 81    /// <summary>
 82    /// NDLRMAF006: Duplicate Order value within the same [AgentSequenceMember] pipeline.
 83    /// </summary>
 184    public static readonly DiagnosticDescriptor DuplicateSequenceOrder = new(
 185        id: MafDiagnosticIds.DuplicateSequenceOrder,
 186        title: "Duplicate Order value in sequential pipeline",
 187        messageFormat: "Pipeline '{0}' has a duplicate Order value ({1}) on '{2}'. Each agent in a sequential pipeline m
 188        category: Category,
 189        defaultSeverity: DiagnosticSeverity.Error,
 190        isEnabledByDefault: true,
 191        description: "Two or more agents in the same [AgentSequenceMember] pipeline declare the same Order value. This i
 192        helpLinkUri: HelpLinkBase + "NDLRMAF006.md",
 193        customTags: WellKnownDiagnosticTags.CompilationEnd);
 94
 95    /// <summary>
 96    /// NDLRMAF007: Gap in Order sequence within the same [AgentSequenceMember] pipeline.
 97    /// </summary>
 198    public static readonly DiagnosticDescriptor GapInSequenceOrder = new(
 199        id: MafDiagnosticIds.GapInSequenceOrder,
 1100        title: "Gap in sequential pipeline Order values",
 1101        messageFormat: "Pipeline '{0}' has a gap in its Order sequence — Order {1} is missing. Use contiguous Order valu
 1102        category: Category,
 1103        defaultSeverity: DiagnosticSeverity.Warning,
 1104        isEnabledByDefault: true,
 1105        description: "The Order values declared via [AgentSequenceMember] for this pipeline are not contiguous. This is 
 1106        helpLinkUri: HelpLinkBase + "NDLRMAF007.md",
 1107        customTags: WellKnownDiagnosticTags.CompilationEnd);
 108
 109    /// <summary>
 110    /// NDLRMAF008: Agent participates in no topology declaration.
 111    /// </summary>
 1112    public static readonly DiagnosticDescriptor OrphanAgent = new(
 1113        id: MafDiagnosticIds.OrphanAgent,
 1114        title: "Agent participates in no topology declaration",
 1115        messageFormat: "'{0}' is decorated with [NeedlrAiAgent] but does not appear in any topology declaration ([AgentH
 1116        category: Category,
 1117        defaultSeverity: DiagnosticSeverity.Info,
 1118        isEnabledByDefault: true,
 1119        description: "An agent registered with [NeedlrAiAgent] is not referenced in any topology. It will not appear in 
 1120        helpLinkUri: HelpLinkBase + "NDLRMAF008.md",
 1121        customTags: WellKnownDiagnosticTags.CompilationEnd);
 122
 123    /// <summary>
 124    /// NDLRMAF009: <c>[WorkflowRunTerminationCondition]</c> declared on a non-agent class.
 125    /// </summary>
 1126    public static readonly DiagnosticDescriptor WorkflowRunTerminationConditionOnNonAgent = new(
 1127        id: MafDiagnosticIds.WorkflowRunTerminationConditionOnNonAgent,
 1128        title: "[WorkflowRunTerminationCondition] declared on a non-agent class",
 1129        messageFormat: "'{0}' has [WorkflowRunTerminationCondition] but is not decorated with [NeedlrAiAgent]. Terminati
 1130        category: Category,
 1131        defaultSeverity: DiagnosticSeverity.Warning,
 1132        isEnabledByDefault: true,
 1133        description: "A class carries [WorkflowRunTerminationCondition] but is not decorated with [NeedlrAiAgent], so it
 1134        helpLinkUri: HelpLinkBase + "NDLRMAF009.md");
 135
 136    /// <summary>
 137    /// NDLRMAF010: Condition type does not implement <c>IWorkflowTerminationCondition</c>.
 138    /// </summary>
 1139    public static readonly DiagnosticDescriptor TerminationConditionTypeInvalid = new(
 1140        id: MafDiagnosticIds.TerminationConditionTypeInvalid,
 1141        title: "Termination condition type does not implement IWorkflowTerminationCondition",
 1142        messageFormat: "'{0}' does not implement IWorkflowTerminationCondition and cannot be used as a termination condi
 1143        category: Category,
 1144        defaultSeverity: DiagnosticSeverity.Error,
 1145        isEnabledByDefault: true,
 1146        description: "The conditionType argument passed to [WorkflowRunTerminationCondition] or [AgentTerminationConditi
 1147        helpLinkUri: HelpLinkBase + "NDLRMAF010.md");
 148
 149    /// <summary>
 150    /// NDLRMAF011: Prefer <c>[AgentTerminationCondition]</c> over
 151    /// <c>[WorkflowRunTerminationCondition]</c> for group chat members.
 152    /// </summary>
 1153    public static readonly DiagnosticDescriptor PreferAgentTerminationConditionForGroupChat = new(
 1154        id: MafDiagnosticIds.PreferAgentTerminationConditionForGroupChat,
 1155        title: "Prefer [AgentTerminationCondition] over [WorkflowRunTerminationCondition] for group chat members",
 1156        messageFormat: "'{0}' is an [AgentGroupChatMember] with [WorkflowRunTerminationCondition]. Consider using [Agent
 1157        category: Category,
 1158        defaultSeverity: DiagnosticSeverity.Info,
 1159        isEnabledByDefault: true,
 1160        description: "For group chat agents, [AgentTerminationCondition] is evaluated inside MAF's group chat loop befor
 1161        helpLinkUri: HelpLinkBase + "NDLRMAF011.md");
 162
 163    /// <summary>
 164    /// NDLRMAF012: <c>[AgentFunction]</c> method has no <c>[Description]</c> attribute.
 165    /// </summary>
 1166    public static readonly DiagnosticDescriptor AgentFunctionMissingDescription = new(
 1167        id: MafDiagnosticIds.AgentFunctionMissingDescription,
 1168        title: "[AgentFunction] method is missing a [Description] attribute",
 1169        messageFormat: "'{0}' is decorated with [AgentFunction] but has no [Description] attribute. Without a descriptio
 1170        category: Category,
 1171        defaultSeverity: DiagnosticSeverity.Warning,
 1172        isEnabledByDefault: true,
 1173        description: "The LLM uses the [Description] text to decide when to invoke an agent function tool. A method with
 1174        helpLinkUri: HelpLinkBase + "NDLRMAF012.md");
 175
 176    /// <summary>
 177    /// NDLRMAF013: Parameter of an <c>[AgentFunction]</c> method is missing a <c>[Description]</c> attribute.
 178    /// </summary>
 1179    public static readonly DiagnosticDescriptor AgentFunctionParameterMissingDescription = new(
 1180        id: MafDiagnosticIds.AgentFunctionParameterMissingDescription,
 1181        title: "[AgentFunction] method parameter is missing a [Description] attribute",
 1182        messageFormat: "Parameter '{0}' on [AgentFunction] method '{1}' has no [Description] attribute. Without a descri
 1183        category: Category,
 1184        defaultSeverity: DiagnosticSeverity.Warning,
 1185        isEnabledByDefault: true,
 1186        description: "Each parameter of an [AgentFunction] method should carry a [Description] attribute so the LLM know
 1187        helpLinkUri: HelpLinkBase + "NDLRMAF013.md");
 188
 189    /// <summary>
 190    /// NDLRMAF014: A type in <c>FunctionTypes</c> on <c>[NeedlrAiAgent]</c> has no
 191    /// <c>[AgentFunction]</c> methods.
 192    /// </summary>
 1193    public static readonly DiagnosticDescriptor AgentFunctionTypesMiswired = new(
 1194        id: MafDiagnosticIds.AgentFunctionTypesMiswired,
 1195        title: "FunctionTypes entry has no [AgentFunction] methods",
 1196        messageFormat: "'{0}' is listed in FunctionTypes on '{1}' but has no methods decorated with [AgentFunction]. The
 1197        category: Category,
 1198        defaultSeverity: DiagnosticSeverity.Warning,
 1199        isEnabledByDefault: true,
 1200        description: "A type referenced in FunctionTypes must contain at least one method decorated with [AgentFunction]
 1201        helpLinkUri: HelpLinkBase + "NDLRMAF014.md");
 202}

Methods/Properties

.cctor()