Jefferson Alves
10c622afa6
fix(providers): default missing cache_control.ttl to 1h on the native Claude OAuth path ( #10221 )
...
Real Claude Code (and CC-protocol-compatible clients) commonly send
`cache_control: { type: "ephemeral" }` with no `ttl`. On the native
Claude OAuth path (provider `claude`/`cc`) the outbound anthropic-beta
set always includes extended-cache-ttl-2025-04-11, so requesting the 1h
TTL is always valid here — but Anthropic only honors it when `ttl` is
explicit; an absent `ttl` silently falls back to the platform default of
5 minutes even though the 1h beta was negotiated.
Practical effect: any pause longer than 5 minutes between turns forces a
full prefix rewrite (tens of thousands of tokens for a typical Claude
Code system+tools prefix) instead of a cache hit, burning through the
subscription's rate limit far faster than native (direct-to-Anthropic)
usage for the same workload.
Adds `normalizeCacheControlTtl()` to claudeCodeConstraints.ts (same
module as the sibling cache_control helpers enforceCacheControlLimit /
ensureCacheControlOnLastUserMessage) and calls it right after the
billing-header system-block manipulation in base.ts, immediately before
the request is signed and sent. Never touches a cache_control that
already specifies a ttl.
Measured before/after with a real Claude Code CLI session through this
path (system + tools prefix ~46k tokens):
before: cache writes always land in ephemeral_5m_input_tokens; a >5min
gap between turns forces a full rewrite (cache_read resets to 0)
after: cache writes land in ephemeral_1h_input_tokens; a >6min gap
survives (cache_read stays intact)
--no-verify note: local pre-commit's check:docs-sync fails on this branch
tip ("CHANGELOG.md first section must be Unreleased") for reasons
unrelated to this diff (pre-existing state of release/v3.8.50 mid-cycle,
CHANGELOG.md untouched by this change). Added the required changelog.d
fragment per CONTRIBUTING.md regardless.
Co-authored-by: Jefferson Alves <jefferson@rastrosystem.com.br >
2026-08-13 00:40:05 -03:00
..
2026-08-11 04:24:54 -03:00
2026-08-06 05:24:21 -03:00
2026-08-10 03:25:13 -03:00
2026-08-13 00:02:25 -03:00
2026-08-12 08:41:03 -03:00
2026-08-11 10:19:21 -03:00
2026-08-11 09:20:41 -03:00
2026-07-21 21:42:36 -03:00
2026-08-11 04:30:29 -03:00
2026-08-12 16:54:50 -03:00
2026-08-12 08:40:18 -03:00
2026-08-10 03:25:02 -03:00
2026-08-11 10:17:31 -03:00
2026-03-05 08:41:44 -03:00
2026-08-09 14:15:53 -03:00
2026-08-09 17:02:47 -03:00
2026-08-11 04:24:35 -03:00
2026-08-09 17:54:23 -03:00
2026-08-09 00:21:52 -03:00
2026-08-03 17:22:08 +03:00
2026-08-09 17:54:23 -03:00
2026-08-09 17:02:47 -03:00
2026-08-09 10:07:17 -03:00
2026-08-09 17:02:47 -03:00
2026-07-18 03:17:09 -03:00
2026-07-18 21:18:34 -03:00
2026-08-11 04:25:23 -03:00
2026-08-11 04:25:23 -03:00
2026-08-11 04:25:23 -03:00
2026-08-11 04:25:23 -03:00
2026-08-11 04:25:23 -03:00
2026-08-11 04:25:23 -03:00
2026-08-06 06:05:58 -03:00
2026-07-22 20:41:19 -03:00
2026-07-22 20:41:19 -03:00
2026-07-22 20:41:19 -03:00
2026-06-29 08:40:06 -03:00
2026-07-22 20:41:19 -03:00
2026-08-05 23:51:36 -03:00
2026-08-09 17:54:23 -03:00
2026-08-11 04:25:13 -03:00
2026-07-19 14:46:33 -03:00
2026-07-22 20:41:19 -03:00
2026-06-29 16:51:03 -03:00
2026-06-29 08:40:06 -03:00
2026-08-08 11:45:54 -03:00
2026-07-13 09:12:40 -03:00
2026-07-21 11:50:14 -03:00
2026-05-26 23:51:47 -03:00
2026-08-13 00:02:25 -03:00
2026-08-12 08:41:03 -03:00
2026-08-12 08:41:03 -03:00
2026-08-11 04:31:24 -03:00
2026-07-20 15:56:40 -03:00
2026-07-06 02:25:17 -03:00
2026-05-29 13:21:36 -03:00
2026-07-27 19:06:59 -03:00
2026-08-11 09:53:39 -03:00
2026-08-09 09:51:56 -03:00
2026-04-13 14:43:32 -03:00
2026-07-25 02:52:55 -03:00
2026-06-16 01:00:40 -03:00
2026-06-27 09:07:12 -03:00
2026-08-13 00:40:05 -03:00
2026-04-19 19:50:30 -03:00
2026-04-12 22:41:12 -03:00
2026-08-06 05:24:13 -03:00
2026-08-11 04:29:52 -03:00
2026-06-25 13:17:40 -03:00
2026-07-27 19:06:59 -03:00
2026-07-19 02:31:26 -03:00
2026-06-25 13:17:40 -03:00
2026-05-15 12:51:07 -03:00
2026-07-21 12:19:01 -03:00
2026-05-02 00:48:54 -03:00
2026-06-29 08:40:06 -03:00
2026-05-23 01:46:59 -03:00
2026-07-04 13:00:30 -03:00
2026-08-05 22:40:33 -03:00
2026-07-04 13:00:30 -03:00
2026-08-11 10:19:21 -03:00
2026-08-11 04:35:20 -03:00
2026-08-06 05:24:39 -03:00
2026-06-23 03:08:29 -03:00
2026-08-11 09:08:23 -03:00
2026-08-11 09:08:23 -03:00
2026-08-11 09:08:23 -03:00
2026-08-11 09:08:23 -03:00
2026-08-11 09:08:23 -03:00
2026-05-29 12:44:29 -03:00
2026-08-11 09:59:45 -03:00
2026-05-24 18:05:58 -03:00
2026-07-13 09:12:40 -03:00
2026-08-07 11:23:27 -03:00
2026-08-11 04:25:23 -03:00
2026-07-13 09:12:40 -03:00
2026-07-19 20:52:54 -03:00
2026-07-04 13:00:30 -03:00
2026-06-13 17:27:40 -03:00
2026-08-10 00:30:10 -03:00
2026-05-26 23:51:47 -03:00
2026-08-09 15:21:37 -03:00
2026-07-18 03:17:09 -03:00
2026-06-29 08:40:06 -03:00
2026-08-06 00:08:52 -03:00
2026-07-23 05:17:35 -03:00
2026-05-29 13:21:36 -03:00
2026-07-13 09:12:40 -03:00
2026-04-11 09:38:17 -03:00
2026-07-25 02:52:55 -03:00
2026-07-17 10:43:37 -03:00
2026-07-23 01:33:32 -03:00
2026-07-20 15:57:29 -03:00
2026-07-20 15:57:29 -03:00
2026-07-26 12:11:02 -03:00
2026-07-27 19:06:59 -03:00
2026-07-04 13:00:30 -03:00
2026-07-19 02:31:26 -03:00
2026-07-26 03:53:06 -03:00
2026-08-12 16:09:34 -03:00
2026-08-11 08:40:48 -03:00
2026-05-23 01:46:59 -03:00
2026-08-05 16:07:21 -03:00
2026-05-24 18:05:58 -03:00
2026-07-13 09:12:40 -03:00
2026-08-05 21:42:52 -03:00
2026-07-13 09:12:40 -03:00
2026-07-27 11:30:33 -03:00
2026-07-27 19:06:59 -03:00
2026-05-10 00:55:06 -03:00
2026-06-19 06:49:01 -03:00
2026-08-06 22:55:27 -03:00
2026-04-12 10:34:10 -03:00
2026-08-12 09:04:41 -03:00
2026-08-12 09:04:41 -03:00
2026-08-12 09:04:41 -03:00
2026-08-12 09:04:41 -03:00
2026-05-29 12:44:29 -03:00
2026-04-22 01:39:49 -03:00
2026-08-06 10:40:20 -03:00
2026-07-23 12:17:58 -03:00
2026-07-27 17:25:43 -03:00
2026-07-27 19:06:59 -03:00
2026-07-22 06:59:24 -03:00
2026-07-20 15:57:15 -03:00
2026-07-20 15:57:15 -03:00
2026-08-11 09:51:35 -03:00
2026-07-14 21:45:23 -03:00
2026-07-13 09:12:40 -03:00
2026-07-20 22:26:13 -03:00
2026-07-18 03:11:01 -03:00
2026-07-18 03:11:01 -03:00
2026-08-05 22:31:10 -03:00
2026-07-27 19:06:59 -03:00
2026-08-06 00:08:52 -03:00
2026-07-21 21:25:00 -03:00
2026-08-04 10:06:31 -03:00
2026-08-11 04:34:23 -03:00
2026-07-25 02:52:55 -03:00
2026-08-06 10:41:04 -03:00
2026-05-10 00:55:06 -03:00
2026-06-07 07:20:02 -03:00
2026-07-27 19:08:12 -03:00
2026-07-27 19:08:12 -03:00
2026-07-04 13:00:30 -03:00
2026-08-06 10:40:20 -03:00
2026-08-06 10:40:20 -03:00
2026-07-13 09:12:40 -03:00
2026-07-27 19:08:05 -03:00
2026-07-27 17:25:47 -03:00
2026-04-13 13:11:30 -03:00
2026-08-13 00:02:25 -03:00
2026-06-21 08:56:51 -03:00
2026-08-07 11:13:20 -03:00
2026-08-09 10:07:03 -03:00
2026-08-05 16:48:50 -03:00
2026-07-20 17:53:04 -03:00
2026-05-29 13:21:36 -03:00
2026-07-13 09:12:40 -03:00
2026-08-09 09:55:02 -03:00
2026-07-22 11:28:16 -03:00
2026-07-21 09:15:27 -03:00
2026-07-02 10:47:13 -03:00
2026-08-06 10:41:04 -03:00
2026-07-13 09:12:40 -03:00
2026-05-29 13:21:36 -03:00
2026-06-04 20:05:38 -03:00
2026-05-29 13:21:36 -03:00
2026-08-06 10:41:04 -03:00
2026-05-10 00:55:06 -03:00
2026-05-10 00:55:06 -03:00
2026-08-05 22:31:10 -03:00
2026-08-10 18:16:13 -03:00
2026-06-25 13:17:40 -03:00
2026-08-06 05:24:13 -03:00
2026-07-18 21:18:34 -03:00
2026-07-27 19:07:30 -03:00
2026-06-25 13:17:40 -03:00
2026-07-02 10:47:13 -03:00
2026-08-10 18:16:13 -03:00
2026-07-20 17:53:04 -03:00
2026-07-20 17:53:04 -03:00
2026-05-10 00:55:06 -03:00
2026-05-10 00:55:06 -03:00
2026-07-27 19:06:59 -03:00
2026-06-13 17:27:40 -03:00
2026-08-12 08:41:03 -03:00
2026-06-19 06:49:01 -03:00
2026-08-12 08:40:18 -03:00
2026-06-04 20:05:38 -03:00
2026-07-06 02:25:17 -03:00
2026-07-07 13:14:06 -03:00
2026-08-11 09:08:23 -03:00
2026-07-18 03:17:09 -03:00
2026-03-30 12:58:45 -03:00
2026-08-03 18:22:14 -03:00
2026-07-27 23:57:23 -03:00
2026-08-07 18:08:44 -03:00
2026-06-22 03:17:02 -03:00
2026-06-08 00:48:01 -03:00
2026-04-17 23:21:02 -03:00
2026-04-03 00:15:35 -03:00
2026-07-26 12:11:02 -03:00
2026-08-12 15:58:40 -03:00