jif
816fa702ec
Account for token usage from incomplete responses ( #53670 )
...
## Why
Terminal `response.incomplete` errors discard reported token usage. Counting that usage as a new context baseline can also double-count input and trigger unnecessary compaction on the next turn.
## What changed
- Carry the response ID and valid reported usage with incomplete-response errors.
- Record usage for sampling and foreground compaction in cumulative totals, rollout records, budgets, and token-usage contributors without replacing the context baseline. Preserve the original terminal error, including when accounting exhausts the budget or cancellation races the error.
- Charge incomplete background compaction requests to the rollout budget without publishing foreground token usage.
- Ignore missing or malformed usage rather than estimating it.
## Testing
Extend coverage for SSE and WebSocket incomplete responses, rollout usage records, compaction accounting, deferred token-count events, and token-usage contributors. Add regressions for unnecessary compaction on the next turn and background compaction publishing foreground usage.
GitOrigin-RevId: bf1ee6df3912052ab7c19e1c6af8ad3dc4b07675
2026-10-13 13:36:24 +00:00
..
2026-10-13 12:42:53 +00:00
2026-07-06 14:29:19 -07:00
2026-10-13 09:06:39 +00:00
2026-10-10 01:25:00 +00:00
2026-10-10 01:25:00 +00:00
2026-10-08 16:19:09 +00:00
2026-10-13 10:21:42 +00:00
2026-10-08 19:29:47 +00:00
2026-09-14 15:30:22 +00:00
2026-10-06 16:56:39 +00:00
2026-08-31 22:38:23 +00:00
2026-10-07 21:52:43 +00:00
2026-10-13 13:36:24 +00:00
2026-10-13 08:44:23 +00:00
2026-10-13 13:36:24 +00:00
2026-10-08 09:39:33 +00:00
2026-10-13 12:59:15 +00:00
2026-10-13 09:34:17 +00:00
2026-08-25 13:10:24 +00:00
2026-10-01 20:17:34 +00:00
2026-10-12 14:44:22 +00:00
2026-10-07 13:05:06 +00:00
2026-10-06 22:39:32 +00:00
2026-09-16 04:59:23 +00:00
2026-09-24 16:36:57 +00:00
2026-09-24 16:36:57 +00:00
2026-10-10 01:25:00 +00:00
2026-10-03 05:59:07 +00:00
2026-10-10 01:25:00 +00:00
2026-10-05 18:52:51 +00:00
2026-09-24 22:54:29 +00:00
2026-10-13 08:13:34 +00:00
2026-10-10 18:26:18 +00:00
2026-10-09 23:26:34 +00:00
2026-10-10 01:25:00 +00:00
2026-10-12 16:09:41 +00:00
2026-10-08 23:57:36 +00:00
2026-10-12 18:53:49 +00:00
2026-09-09 18:40:53 +00:00
2026-10-13 08:13:34 +00:00
2026-10-13 09:18:45 +00:00
2026-10-10 01:25:00 +00:00
2026-10-10 01:25:00 +00:00
2026-10-13 09:18:45 +00:00
2026-10-13 13:36:24 +00:00
2026-10-10 17:30:25 +00:00
2026-10-10 01:25:00 +00:00
2026-10-05 16:10:27 +00:00
2026-10-13 13:36:24 +00:00
2026-09-01 13:43:27 +00:00
2026-09-26 23:17:41 +00:00
2026-06-24 22:17:43 -07:00
2026-10-09 20:14:04 +00:00
2026-07-06 11:20:32 -07:00
2026-07-06 11:20:32 -07:00
2026-10-06 22:39:32 +00:00
2026-10-09 19:06:34 +00:00
2026-10-10 01:25:00 +00:00
2026-10-10 01:25:00 +00:00
2026-10-05 23:52:06 +00:00
2026-10-08 13:45:19 +00:00
2026-09-01 14:43:27 +00:00
2026-08-20 07:03:02 +00:00
2026-10-08 16:19:09 +00:00
2026-10-07 21:52:43 +00:00
2026-10-07 21:52:43 +00:00
2026-09-18 23:07:36 +00:00
2026-09-18 23:07:36 +00:00
2026-10-07 03:07:51 +00:00
2026-10-01 15:57:03 +00:00
2026-09-28 17:29:52 +00:00
2026-10-08 23:57:36 +00:00
2026-10-08 23:57:36 +00:00
2026-10-10 01:25:00 +00:00
2026-10-08 23:57:36 +00:00
2026-10-13 12:59:15 +00:00
2026-10-01 05:33:36 +00:00
2026-10-08 18:42:58 +00:00
2026-08-29 06:05:28 +00:00
2026-10-08 18:42:58 +00:00
2026-10-08 17:25:09 +00:00
2026-08-06 13:37:07 +00:00
2026-10-07 16:35:05 +00:00
2026-10-08 18:42:58 +00:00
2026-09-16 15:17:41 +00:00
2026-09-26 18:36:55 +00:00
2026-09-23 22:10:04 +00:00
2026-07-06 14:51:34 -07:00
2026-10-08 21:18:24 +00:00
2026-10-06 21:28:13 +00:00
2026-10-10 01:25:00 +00:00
2026-08-17 04:01:37 +00:00
2026-10-07 01:28:59 +00:00
2026-10-09 02:04:35 +00:00
2026-10-06 19:29:40 +00:00
2026-08-31 22:38:23 +00:00
2026-06-01 18:45:07 +00:00
2026-09-15 17:09:11 +00:00
2026-10-08 23:34:16 +00:00
2026-09-29 02:05:56 +00:00
2026-09-30 02:12:42 +00:00
2026-09-19 01:03:55 +00:00
2026-07-23 19:19:35 +00:00
2026-09-24 16:36:57 +00:00
2026-09-24 16:36:57 +00:00
2026-08-31 23:29:20 +00:00
2026-09-17 18:20:28 +00:00
2026-09-29 16:53:11 +00:00
2026-09-29 16:53:11 +00:00
2026-08-24 10:56:54 +00:00
2026-10-07 17:59:22 +00:00
2026-10-07 21:52:43 +00:00
2026-10-08 22:27:00 +00:00
2026-10-08 13:45:19 +00:00
2026-09-30 03:22:55 +00:00
2026-09-30 03:22:55 +00:00
2026-10-06 21:29:35 +00:00
2026-10-08 16:19:09 +00:00
2026-10-10 01:25:00 +00:00
2026-10-10 01:25:00 +00:00
2026-09-24 18:07:37 +00:00
2026-10-10 01:25:00 +00:00
2026-10-12 16:09:41 +00:00
2026-10-10 01:25:00 +00:00
2026-10-06 10:39:16 +00:00
2026-10-13 12:59:15 +00:00
2026-10-02 16:55:41 +00:00
2026-07-22 02:19:45 +00:00
2026-07-22 02:19:45 +00:00
2026-10-01 03:31:48 +00:00
2026-10-08 23:34:16 +00:00
2026-10-06 01:26:11 +00:00
2026-10-10 01:25:00 +00:00
2026-10-04 21:19:05 +00:00
2026-08-25 17:41:22 +00:00
2026-05-14 16:54:59 -07:00
2026-09-18 00:25:37 +00:00
2026-07-20 13:45:29 +00:00
2026-05-28 15:26:55 -07:00
2026-05-28 15:26:55 -07:00
2026-09-19 01:21:32 +00:00
2026-10-08 06:31:56 +00:00
2026-09-09 19:31:12 +00:00
2026-09-23 18:40:12 +00:00