@warlock.js/ai-anthropic 5.60.0 → 5.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to `@warlock.js/ai-anthropic` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.62.0 - 2026-11-20
8
+
9
+ ### Fixed
10
+
11
+ - With `promptCaching: true`, a per-call `cacheControl: { breakpoints: n }` no longer removes the request-level `cache_control` marker. The automatic marker (the conversation prefix, cached across trips), the tools marker and the system marker are sent together (3 of the 4 breakpoints a request may carry), so a multi-trip agent that sets `breakpoints: 1` keeps reading its history from cache.
12
+
7
13
  ## 5.54.0 - 2026-11-16
8
14
 
9
15
  ### Fixed
package/cjs/index.cjs CHANGED
@@ -1753,9 +1753,11 @@ var AnthropicModel = class {
1753
1753
  * the system prompt is emitted as a single `TextBlockParam` carrying
1754
1754
  * `cache_control: ephemeral` — the system prompt is the longest stable
1755
1755
  * prefix on a turn, so one breakpoint there lets multi-turn agents
1756
- * read it back at the ~0.1x cache-read rate. Without the hint the
1757
- * system prompt stays a plain string (left uncached) so a one-shot
1758
- * call never pays the ~1.25x cache-write surcharge.
1756
+ * read it back at the ~0.1x cache-read rate. This marker is added
1757
+ * alongside the request-level automatic marker (see
1758
+ * `buildAutomaticCacheControl`), never instead of it. Without the hint
1759
+ * the system prompt stays a plain string with no marker of its own, so
1760
+ * a one-shot call never pays the ~1.25x cache-write surcharge.
1759
1761
  */
1760
1762
  buildSystem(system, cacheControl) {
1761
1763
  if (!system) return {};
@@ -1768,13 +1770,17 @@ var AnthropicModel = class {
1768
1770
  return { system };
1769
1771
  }
1770
1772
  /**
1771
- * Let Anthropic select the last cacheable block when caching is enabled
1772
- * without a caller-selected breakpoint. An explicit breakpoint remains
1773
- * authoritative, so the request-level form is deliberately omitted then.
1773
+ * Request-level `cache_control` (Anthropic automatic caching) whenever
1774
+ * `promptCaching` is on. Anthropic places it on the last cacheable block,
1775
+ * so the rolling conversation prefix is read back across trips. It stays
1776
+ * in place when explicit `cacheControl.breakpoints` are set: the tools
1777
+ * marker, the system marker and this one make 3 markers, within
1778
+ * Anthropic's limit of 4 per request. The adapter sets no other markers
1779
+ * (messages are never marked), and one TTL applies to all of them, so the
1780
+ * "1h entries before 5m entries" ordering rule cannot be violated.
1774
1781
  */
1775
1782
  buildAutomaticCacheControl(cacheControl) {
1776
- const breakpoints = cacheControl?.breakpoints ?? 0;
1777
- return this.config.promptCaching && breakpoints <= 0 ? { cache_control: this.cacheControl(cacheControl?.ttl) } : {};
1783
+ return this.config.promptCaching ? { cache_control: this.cacheControl(cacheControl?.ttl) } : {};
1778
1784
  }
1779
1785
  /**
1780
1786
  * Build a typed cache-control marker. The per-call