< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Workflows.Diagnostics.ToolCallCollector
Assembly: NexusLabs.Needlr.AgentFramework.Workflows
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Diagnostics/ToolCallCollector.cs
Line coverage
57%
Covered lines: 4
Uncovered lines: 3
Coverable lines: 7
Total lines: 29
Line coverage: 57.1%
Branch coverage
50%
Covered branches: 1
Total branches: 2
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%
Add(...)100%210%
DrainToolCalls()50%2260%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Diagnostics/ToolCallCollector.cs

#LineLine coverage
 1using System.Collections.Concurrent;
 2
 3using NexusLabs.Needlr.AgentFramework.Diagnostics;
 4
 5namespace NexusLabs.Needlr.AgentFramework.Workflows.Diagnostics;
 6
 7/// <summary>
 8/// Thread-safe collector for tool call diagnostics captured by the function-calling
 9/// middleware. Analogous to <see cref="DiagnosticsChatClientMiddleware"/>'s completion
 10/// collection, ensuring tool calls are not lost when AsyncLocal builders don't propagate.
 11/// </summary>
 12internal sealed class ToolCallCollector : IToolCallCollector
 13{
 3514    private readonly ConcurrentQueue<ToolCallDiagnostics> _toolCalls = new();
 15
 16    internal void Add(ToolCallDiagnostics diagnostics) =>
 017        _toolCalls.Enqueue(diagnostics);
 18
 19    /// <inheritdoc />
 20    public IReadOnlyList<ToolCallDiagnostics> DrainToolCalls()
 21    {
 1822        var results = new List<ToolCallDiagnostics>();
 1823        while (_toolCalls.TryDequeue(out var toolCall))
 24        {
 025            results.Add(toolCall);
 026        }
 1827        return results;
 28    }
 29}