Read the reported token usage in one place

This commit is contained in:
Thorsten Sommer committed 2026-09-23 18:26:18 +02:00
1 parent bbd73f389b
commit ceb78ff9b7
7 files changed
+23 -31

No files matched your search

@@ -1123,11 +1123,12 @@ public abstract class BaseProvider : IProvider, ISecretId
// 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())
var usage = providerResponse.GetUsage();
if (usage.IsKnown)
{
yield return providerResponse.ContainsContent()
? providerResponse.GetContent() with { Usage = providerResponse.GetUsage() }
: new(string.Empty, [], providerResponse.GetUsage());
? providerResponse.GetContent() with { Usage = usage }
: new(string.Empty, [], usage);
continue;
}