< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Iterative.StallDetectionOptions
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Iterative/StallDetectionOptions.cs
Line coverage
83%
Covered lines: 10
Uncovered lines: 2
Coverable lines: 12
Total lines: 52
Line coverage: 83.3%
Branch coverage
50%
Covered branches: 4
Total branches: 8
Branch coverage: 50%
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_ConsecutiveThreshold()100%11100%
set_ConsecutiveThreshold(...)50%2275%
get_TolerancePercent()100%11100%
set_TolerancePercent(...)50%7675%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Iterative/StallDetectionOptions.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Iterative;
 2
 3/// <summary>
 4/// Configuration for iterative loop stall detection.
 5/// </summary>
 6/// <remarks>
 7/// A "stall" is detected when <see cref="ConsecutiveThreshold"/> consecutive
 8/// iterations produce total token counts within <see cref="TolerancePercent"/>
 9/// of each other. This is a strong signal the LLM is repeating the same work
 10/// because it has no cross-iteration memory of what it already did.
 11/// </remarks>
 12public sealed class StallDetectionOptions
 13{
 414    private int _consecutiveThreshold = 3;
 415    private double _tolerancePercent = 0.10;
 16
 17    /// <summary>
 18    /// The number of consecutive iterations with similar token counts before
 19    /// terminating. Defaults to <c>3</c>. Minimum <c>2</c>.
 20    /// </summary>
 21    /// <exception cref="ArgumentOutOfRangeException">Value is less than 2.</exception>
 22    public int ConsecutiveThreshold
 23    {
 1324        get => _consecutiveThreshold;
 25        set
 26        {
 427            if (value < 2)
 028                throw new ArgumentOutOfRangeException(nameof(value), "ConsecutiveThreshold must be at least 2.");
 429            _consecutiveThreshold = value;
 430        }
 31    }
 32
 33    /// <summary>
 34    /// How close token counts must be (as a fraction of the previous iteration's
 35    /// count) to be considered "similar." Defaults to <c>0.10</c> (10%).
 36    /// </summary>
 37    /// <remarks>
 38    /// A tolerance of 0.10 means iterations with 15,000 and 16,200 tokens are
 39    /// considered similar (8% difference), but 15,000 and 18,000 are not (20%).
 40    /// </remarks>
 41    /// <exception cref="ArgumentOutOfRangeException">Value is negative or ≥ 1.0.</exception>
 42    public double TolerancePercent
 43    {
 1744        get => _tolerancePercent;
 45        set
 46        {
 447            if (value is < 0.0 or >= 1.0)
 048                throw new ArgumentOutOfRangeException(nameof(value), "TolerancePercent must be between 0.0 (inclusive) a
 449            _tolerancePercent = value;
 450        }
 51    }
 52}