< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Diagnostics.IAgentDiagnosticsAccessor
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Diagnostics/IAgentDiagnosticsAccessor.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 51
Line coverage: 0%
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
get_CompletionCollector()100%210%
get_ToolCallCollector()100%210%

File(s)

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

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Diagnostics;
 2
 3/// <summary>
 4/// Provides access to the diagnostics captured during the most recent agent run in the current
 5/// async flow. Uses the mutable-holder <see cref="AsyncLocal{T}"/> pattern so that writes from
 6/// child async flows (inside middleware) are visible to the parent scope.
 7/// </summary>
 8/// <remarks>
 9/// <para>
 10/// Callers wrap agent execution in <see cref="BeginCapture"/>:
 11/// </para>
 12/// <code>
 13/// using (diagnosticsAccessor.BeginCapture())
 14/// {
 15///     await agent.RunAsync(prompt);
 16///     var diagnostics = diagnosticsAccessor.LastRunDiagnostics;
 17///     // diagnostics contains token usage, tool calls, timing, etc.
 18/// }
 19/// </code>
 20/// </remarks>
 21public interface IAgentDiagnosticsAccessor
 22{
 23    /// <summary>
 24    /// Gets the diagnostics from the last completed agent run in the current scope,
 25    /// or <see langword="null"/> if no run has completed yet.
 26    /// </summary>
 27    IAgentRunDiagnostics? LastRunDiagnostics { get; }
 28
 29    /// <summary>
 30    /// Opens a capture scope. Diagnostics written by middleware during agent execution
 31    /// are visible via <see cref="LastRunDiagnostics"/> after the run completes.
 32    /// Disposing the returned handle restores the previous scope.
 33    /// </summary>
 34    IDisposable BeginCapture();
 35
 36    /// <summary>
 37    /// Gets the <see cref="IChatCompletionCollector"/> wired by the diagnostics system,
 38    /// or <see langword="null"/> if diagnostics were not configured. Used as a fallback
 39    /// when <see cref="LastRunDiagnostics"/> is unavailable (e.g., when AsyncLocal state
 40    /// does not propagate across workflow execution boundaries).
 41    /// </summary>
 042    IChatCompletionCollector? CompletionCollector => null;
 43
 44    /// <summary>
 45    /// Gets the <see cref="IToolCallCollector"/> wired by the diagnostics system,
 46    /// or <see langword="null"/> if diagnostics were not configured. Used as a fallback
 47    /// when <see cref="LastRunDiagnostics"/> is unavailable (e.g., when AsyncLocal state
 48    /// does not propagate across workflow execution boundaries).
 49    /// </summary>
 050    IToolCallCollector? ToolCallCollector => null;
 51}