< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.AgentHandoffsToAttribute
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AgentHandoffsToAttribute.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 53
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_TargetAgentType()100%11100%
get_HandoffReason()100%11100%

File(s)

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

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework;
 2
 3/// <summary>
 4/// Declares a handoff target for a <see cref="NeedlrAiAgentAttribute"/>-annotated agent.
 5/// Apply this attribute one or more times to specify which agents the decorated agent can hand off
 6/// to when used as the initial agent in a handoff workflow via
 7/// <see cref="IWorkflowFactory.CreateHandoffWorkflow{TInitialAgent}"/>.
 8/// </summary>
 9/// <remarks>
 10/// When the <c>NexusLabs.Needlr.AgentFramework.Generators</c> package is referenced, the source
 11/// generator emits a strongly-typed extension method (e.g. <c>CreateTriageHandoffWorkflow</c>)
 12/// on <see cref="IWorkflowFactory"/> for each agent type that carries this attribute. The generated
 13/// method encapsulates the agent type so the composition root requires no direct type references.
 14/// </remarks>
 15/// <example>
 16/// <code>
 17/// [NeedlrAiAgent(Instructions = "Triage incoming customer requests.")]
 18/// [AgentHandoffsTo(typeof(BillingAgent),  "Route billing or payment questions to the billing agent")]
 19/// [AgentHandoffsTo(typeof(SupportAgent),  "Route general support requests to the support agent")]
 20/// public class TriageAgent { }
 21///
 22/// // The source generator emits:
 23/// //   workflowFactory.CreateTriageAgentHandoffWorkflow()
 24/// // which wires all handoffs without requiring direct type references at the call site.
 25/// </code>
 26/// </example>
 27[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
 28public sealed class AgentHandoffsToAttribute : Attribute
 29{
 30    /// <summary>
 31    /// Initializes a new instance of <see cref="AgentHandoffsToAttribute"/>.
 32    /// </summary>
 33    /// <param name="targetAgentType">
 34    /// The type of the target agent. Must be annotated with <see cref="NeedlrAiAgentAttribute"/>.
 35    /// </param>
 36    /// <param name="handoffReason">
 37    /// A description of when the decorated agent should hand off to <paramref name="targetAgentType"/>.
 38    /// Passed to the underlying MAF handoff builder as the tool description. When <see langword="null"/>,
 39    /// MAF derives the reason from the target agent's description or name.
 40    /// </param>
 40241    public AgentHandoffsToAttribute(Type targetAgentType, string? handoffReason = null)
 42    {
 40243        ArgumentNullException.ThrowIfNull(targetAgentType);
 40244        TargetAgentType = targetAgentType;
 40245        HandoffReason = handoffReason;
 40246    }
 47
 48    /// <summary>Gets the type of the target agent to hand off to.</summary>
 1249    public Type TargetAgentType { get; }
 50
 51    /// <summary>Gets the optional reason describing when to hand off to <see cref="TargetAgentType"/>.</summary>
 1252    public string? HandoffReason { get; }
 53}