Skip to content

MicrosoftExtensions: Cached Input Token counts are incorrectly doubled #74

@PederHP

Description

@PederHP

Summing up usage during streaming gives twice the expected number (the one reported in the Anthropic console logs, and the one matching tokens actually sent).

UsageContent content = fromSomewhereElse();
var tokens = usage.AdditionalCounts?.GetValueOrDefault("CacheCreationInputTokens")`;

This is on next and with 10.0.1 of Microsoft.Extensions.AI.

Edit: Same with cache hits

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsdk

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions