Added the exact token count where the provider reports it

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
j-erlerandClaude Opus 5 committed 2026-09-20 17:42:29 +02:00
1 parent c95cc5bacc
commit 0aa3b23b81
21 files changed
+598 -7

No files matched your search

@@ -1037,6 +1037,20 @@ public abstract class BaseProvider : IProvider, ISecretId
continue;
}
//
// The line stating what the request cost carries no content of its own: providers
// send it as the last line of the stream, with no choices at all. It is handled
// before the check below, which would otherwise drop it as an empty response.
//
if (providerResponse.ContainsUsage())
{
yield return providerResponse.ContainsContent()
? providerResponse.GetContent() with { Usage = providerResponse.GetUsage() }
: new(string.Empty, [], providerResponse.GetUsage());
continue;
}
// Skip empty responses:
if (!providerResponse.ContainsContent())
continue;