Fixed the exact token count outliving the conversation it was reported for

This commit is contained in:
Thorsten Sommer committed 2026-09-23 18:36:25 +02:00
1 parent 4918858650
commit c23ce9e12a
6 files changed
+239 -52

No files matched your search

@@ -37,6 +37,20 @@ public sealed record ReportedTokenUsage
/// </remarks>
public string ModelId { get; init; } = string.Empty;
/// <summary>
/// How many blocks the conversation had when the request went out, this answer included.
/// </summary>
/// <remarks>
/// What tells an outdated report apart without anybody having to remember anything about it.
/// Blocks are only ever added at the end, so while this answer is the last block, a thread with
/// the same count is the thread the provider saw. A lower count means an earlier message was
/// deleted, and that message is still inside the reported number.
///
/// Taken when the request is sent rather than when the report arrives: whatever is deleted
/// while the answer streams in was still part of what the provider counted.
/// </remarks>
public int BlockCount { get; init; }
/// <summary>
/// States the stored numbers as a usage again.
/// </summary>