Etgpao and CaIon
1b63c28dcc
fix(claude): preserve explicit zero usage and cache-only billing ( #7816 )
...
* fix(claude): preserve explicit zero usage during stream finalization
* test: use synthetic values for Claude usage regressions
* fix(claude): estimate stream usage only when the counts are missing
Trusting every explicit zero let an upstream that reports zeros stream
output for free, and a zero in message_delta erased the input counted
at message_start. Decide from the counts instead: input is missing only
when input, cache reads and cache writes are all zero, and output only
when it is zero after streamed content. A broken stream still takes the
larger of the reported and estimated output. A fully cached prompt and
a refusal before any output keep their zeros, so relaykit usage parsing
goes back to its previous form.
---------
Co-authored-by: CaIon <[email protected] >
2026-10-14 22:31:33 +08:00
..
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-09-30 20:52:36 +08:00
2026-09-11 23:15:29 +08:00
2025-06-07 12:26:23 +08:00
2026-10-09 21:39:51 +08:00
2026-09-30 17:24:19 +08:00
2026-09-30 17:24:19 +08:00
2026-09-30 17:24:19 +08:00
2026-09-08 20:55:03 +08:00
2026-10-09 21:39:51 +08:00
2026-09-03 11:28:57 +08:00
2026-10-09 21:39:51 +08:00
2026-09-18 11:24:29 +08:00
2026-07-27 15:56:21 +08:00
2026-10-09 21:39:51 +08:00
2026-08-01 23:19:01 +08:00
2026-09-11 21:44:56 +08:00
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-10-10 14:02:06 +08:00
2026-10-09 21:39:51 +08:00
2026-07-20 18:11:22 +08:00
2026-07-18 13:04:16 +08:00
2026-06-12 23:45:15 +08:00
2026-06-19 16:07:32 +08:00
2026-07-27 15:56:21 +08:00
2026-07-27 15:56:21 +08:00
2026-10-09 21:39:51 +08:00
2026-09-08 20:55:03 +08:00
2025-10-11 15:30:09 +08:00
2026-09-08 20:55:03 +08:00
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-09-08 20:55:03 +08:00
2026-08-01 23:19:01 +08:00
2026-10-09 21:39:51 +08:00
2026-10-10 14:02:06 +08:00
2026-10-10 14:02:06 +08:00
2026-10-10 14:02:06 +08:00
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-09-20 22:17:20 +08:00
2026-10-09 21:39:51 +08:00
2026-10-12 21:33:53 +08:00
2026-10-09 21:39:51 +08:00
2026-09-18 23:00:37 +08:00
2026-10-09 21:39:51 +08:00
2026-09-08 20:55:03 +08:00
2026-09-06 22:48:59 +08:00
2026-07-27 15:56:21 +08:00
2026-07-27 15:56:21 +08:00
2026-07-06 14:52:01 +08:00
2026-09-30 21:49:33 +08:00
2026-09-08 20:55:03 +08:00
2026-10-09 21:39:51 +08:00
2026-09-08 20:55:03 +08:00
2026-09-18 11:24:29 +08:00
2026-10-09 21:39:51 +08:00
2026-09-01 21:53:35 +08:00
2026-09-18 11:24:29 +08:00
2026-09-01 21:53:35 +08:00
2026-10-07 23:29:24 +08:00
2026-10-07 23:29:24 +08:00
2026-07-20 16:48:43 +08:00
2026-07-20 16:48:43 +08:00
2026-09-30 20:52:36 +08:00
2026-07-27 15:56:21 +08:00
2025-08-15 16:54:26 +08:00
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-06-24 17:16:21 +08:00
2026-10-09 21:39:51 +08:00
2026-08-29 18:51:57 +08:00
2026-08-29 18:51:57 +08:00
2026-08-29 18:51:57 +08:00
2026-08-29 18:51:57 +08:00
2026-10-09 21:39:51 +08:00
2026-10-12 16:58:16 +08:00
2026-09-08 20:55:03 +08:00
2026-09-30 17:24:19 +08:00
2026-08-29 18:51:57 +08:00
2026-10-09 21:39:51 +08:00
2026-10-10 14:02:06 +08:00
2025-10-11 15:30:09 +08:00
2026-10-14 22:31:33 +08:00
2026-10-14 22:31:33 +08:00
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-10-07 21:26:35 +08:00
2026-09-06 22:48:59 +08:00
2026-10-07 21:26:35 +08:00
2026-10-09 21:39:51 +08:00
2026-10-09 21:39:51 +08:00
2026-09-30 21:49:33 +08:00
2026-10-09 21:39:51 +08:00
2026-09-14 21:04:26 +08:00