@absolutejs/ai 0.3.3 → 0.3.4

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
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.3.4 — 2026-10-15
10
+
11
+ ### Fixed
12
+
13
+ - **Keep a prompt-cache breakpoint on the previous turn's user message as well as the last message, so an agent loop's next request reads its cached history by exact position instead of re-writing it; a production Studio build re-wrote its whole history on 7 of 48 requests and those writes were about half its cost.** (`anthropic`)
14
+
9
15
  ## 0.3.3 — 2026-10-10
10
16
 
11
17
  ### Fixed
package/changelog.json CHANGED
@@ -2,6 +2,19 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/ai",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "fixed",
9
+ "summary": "Keep a prompt-cache breakpoint on the previous turn's user message as well as the last message, so an agent loop's next request reads its cached history by exact position instead of re-writing it; a production Studio build re-wrote its whole history on 7 of 48 requests and those writes were about half its cost.",
10
+ "symbols": [
11
+ "anthropic"
12
+ ]
13
+ }
14
+ ],
15
+ "date": "2026-10-15",
16
+ "version": "0.3.4"
17
+ },
5
18
  {
6
19
  "changes": [
7
20
  {
package/dist/ai/index.js CHANGED
@@ -6735,9 +6735,15 @@ var buildRequestBody3 = (params, configuredMax, configCaching) => {
6735
6735
  const options = requestOptionsFor(params);
6736
6736
  const messages = params.messages.filter((msg) => msg.role !== "system").map(mapMessage);
6737
6737
  if (caching && messages.length > 1) {
6738
- const last = messages[messages.length - 1];
6738
+ const lastIndex = messages.length - 1;
6739
+ const last = messages[lastIndex];
6739
6740
  if (last) {
6740
- messages[messages.length - 1] = cacheLastContentBlock(last);
6741
+ messages[lastIndex] = cacheLastContentBlock(last);
6742
+ }
6743
+ const previousUserIndex = messages.findLastIndex((message, index) => index < lastIndex - 1 && message.role === "user");
6744
+ const previous = messages[previousUserIndex];
6745
+ if (previous) {
6746
+ messages[previousUserIndex] = cacheLastContentBlock(previous);
6741
6747
  }
6742
6748
  }
6743
6749
  const max = typeof params.maxTokens === "number" ? params.maxTokens : configuredMax;
@@ -9056,5 +9062,5 @@ export {
9056
9062
  xai
9057
9063
  };
9058
9064
 
9059
- //# debugId=C9BA825E688A09A764756E2164756E21
9065
+ //# debugId=16913D2F7231C56164756E2164756E21
9060
9066
  //# sourceMappingURL=index.js.map