< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Workflows.Middleware.InMemoryTranscriptWriter
Assembly: NexusLabs.Needlr.AgentFramework.Workflows
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Middleware/InMemoryTranscriptWriter.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 44
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_Entries()100%11100%
WriteRequest(...)100%11100%
WriteResponse(...)100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Middleware/InMemoryTranscriptWriter.cs

#LineLine coverage
 1using Microsoft.Extensions.AI;
 2
 3namespace NexusLabs.Needlr.AgentFramework.Workflows.Middleware;
 4
 5/// <summary>
 6/// In-memory <see cref="ITranscriptWriter"/> that stores entries in a list.
 7/// Useful for testing and scenarios where transcript data is consumed
 8/// programmatically after execution.
 9/// </summary>
 10[DoNotAutoRegister]
 11public sealed class InMemoryTranscriptWriter : ITranscriptWriter
 12{
 613    private readonly List<TranscriptEntry> _entries = [];
 14
 15    /// <summary>
 16    /// Gets the transcript entries recorded so far, in order.
 17    /// </summary>
 2018    public IReadOnlyList<TranscriptEntry> Entries => _entries;
 19
 20    /// <inheritdoc />
 21    public void WriteRequest(
 22        string stageName,
 23        IEnumerable<ChatMessage> messages,
 24        ChatOptions? options)
 25    {
 526        _entries.Add(new TranscriptEntry(
 527            stageName,
 528            TranscriptEntryKind.Request,
 529            messages.ToList(),
 530            options,
 531            Response: null));
 532    }
 33
 34    /// <inheritdoc />
 35    public void WriteResponse(string stageName, ChatResponse response)
 36    {
 537        _entries.Add(new TranscriptEntry(
 538            stageName,
 539            TranscriptEntryKind.Response,
 540            Messages: null,
 541            Options: null,
 542            response));
 543    }
 44}