| | | 1 | | namespace 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)] |
| | | 16 | | public 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> |
| | 6788 | 26 | | public AgentGroupChatMemberAttribute(string groupName) |
| | | 27 | | { |
| | 6788 | 28 | | ArgumentException.ThrowIfNullOrWhiteSpace(groupName); |
| | 6788 | 29 | | GroupName = groupName; |
| | 6788 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the name of the group chat this agent participates in.</summary> |
| | 182 | 33 | | 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> |
| | 2235 | 57 | | public int Order { get; set; } |
| | | 58 | | } |