AntFleet

Disagreement · 8ff8c1af-anthropic-0

Anthropic streamMessage discards inputTokens/outputTokens on abort instead of returning partial usage

solo Opus
repo 56f59a0d·PR #2·reviewed 4 days ago

Opus finding

Anthropic streamMessage discards inputTokens/outputTokens on abort instead of returning partial usage

lowbughigh
  • src/providers/anthropic.ts:116-134
On abort the partial response is returned with inputTokens/outputTokens hardcoded to 0, even though the stream may have emitted tokens. Telemetry/cost accounting will under-report aborted requests. The non-aborted path computes them from finalMessage. At minimum, partial-output length could be used as an estimate, or these fields should be left undefined to signal unknown rather than misreporting zero.

Recommendation

Track running input/output token counts from message_start / message_delta SSE events and return them on abort, or omit usage when unknown.

Other reviewer

The other reviewer flagged nothing in this file/line range.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →

From the same review

These findings passed the unanimous gate on the same PR review. The disagreement above was filtered out; the findings below were posted.