< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.AgentGroupChatMemberAttribute
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AgentGroupChatMemberAttribute.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 58
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
.ctor(...)100%11100%
get_GroupName()100%11100%
get_Order()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AgentGroupChatMemberAttribute.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework;
 2
 3/// <summary>
 4/// Declares that a <see cref="NeedlrAiAgentAttribute"/>-annotated agent participates in a named
 5/// group chat workflow. Apply this attribute to include the agent in a round-robin group chat
 6/// created via <see cref="IWorkflowFactory.CreateGroupChatWorkflow(string, int)"/>.
 7/// </summary>
 8/// <remarks>
 9/// When the <c>NexusLabs.Needlr.AgentFramework.Generators</c> package is referenced, the source
 10/// generator emits a strongly-typed extension method (e.g. <c>CreateCodeReviewGroupChatWorkflow</c>)
 11/// on <see cref="IWorkflowFactory"/> for each unique group name declared across all agent types.
 12/// The generated method encapsulates the group name string so the composition root never references
 13/// it directly.
 14/// </remarks>
 15[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
 16public sealed class AgentGroupChatMemberAttribute : Attribute
 17{
 18    /// <summary>
 19    /// Initializes a new instance of <see cref="AgentGroupChatMemberAttribute"/>.
 20    /// </summary>
 21    /// <param name="groupName">
 22    /// The name of the group chat this agent participates in. Must match exactly (case-sensitive)
 23    /// when calling <see cref="IWorkflowFactory.CreateGroupChatWorkflow(string, int)"/>. Use the generated
 24    /// extension method to avoid referencing the string directly.
 25    /// </param>
 678826    public AgentGroupChatMemberAttribute(string groupName)
 27    {
 678828        ArgumentException.ThrowIfNullOrWhiteSpace(groupName);
 678829        GroupName = groupName;
 678830    }
 31
 32    /// <summary>Gets the name of the group chat this agent participates in.</summary>
 18233    public string GroupName { get; }
 34
 35    /// <summary>
 36    /// Gets or sets the position of this agent in the round-robin turn order.
 37    /// Lower values run first. Agents with the same order are sorted alphabetically
 38    /// by type name for deterministic ordering.
 39    /// </summary>
 40    /// <remarks>
 41    /// <para>
 42    /// In a writer/reviewer group chat, the writer should have a lower order than
 43    /// the reviewer so it produces content before the reviewer evaluates it:
 44    /// </para>
 45    /// <code>
 46    /// [AgentGroupChatMember("article-writing", Order = 1)]
 47    /// public sealed class ArticleWriterAgent;
 48    ///
 49    /// [AgentGroupChatMember("article-writing", Order = 2)]
 50    /// public sealed class ArticleReviewerAgent;
 51    /// </code>
 52    /// <para>
 53    /// Defaults to <c>0</c>. When all agents have the default order, the round-robin
 54    /// position is determined alphabetically by type name.
 55    /// </para>
 56    /// </remarks>
 223557    public int Order { get; set; }
 58}