mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-12 12:13:21 +00:00
When an upstream reports a non-zero USD cost but the response carries no tokens at all (input, output, cache-read and cache-creation all zero), the USD path billed the full USD-derived amount for an empty response. Return an all-zero cost (full refund) for that case only. The gate is tightened relative to the superseded PR #489: a cache-read- or cache-creation-only turn legitimately reports zero prompt/completion tokens with a real cost and must still be billed, so the refund only fires when every token bucket is zero. Adds unit tests covering both the refund and the still-billed cache-only path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>