@ai-sdk/anthropic 3.0.46 → 3.0.47

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.
@@ -282,19 +282,25 @@ const result = await generateText({
282
282
  console.log(result.providerMetadata?.anthropic?.contextManagement);
283
283
  ```
284
284
 
285
- #### Clear Tool Uses
285
+ #### Context Editing
286
286
 
287
- The `clear_tool_uses_20250919` edit type removes old tool calls from the conversation history:
287
+ Context editing strategies selectively remove specific content types from earlier in the conversation to reduce token usage without losing the overall conversation flow.
288
288
 
289
- - **trigger** - Condition that triggers the clearing (e.g., `{ type: 'input_tokens', value: 10000 }`)
289
+ ##### Clear Tool Uses
290
+
291
+ The `clear_tool_uses_20250919` edit type removes old tool call/result pairs from the conversation history:
292
+
293
+ - **trigger** - Condition that triggers the clearing (e.g., `{ type: 'input_tokens', value: 10000 }` or `{ type: 'tool_uses', value: 10 }`)
290
294
  - **keep** - How many recent tool uses to preserve (e.g., `{ type: 'tool_uses', value: 5 }`)
291
295
  - **clearAtLeast** - Minimum amount to clear (e.g., `{ type: 'input_tokens', value: 1000 }`)
292
296
  - **clearToolInputs** - Whether to clear tool input parameters (boolean)
293
297
  - **excludeTools** - Array of tool names to never clear
294
298
 
295
- #### Clear Thinking
299
+ ##### Clear Thinking
296
300
 
297
- The `clear_thinking_20251015` edit type removes thinking/reasoning content:
301
+ The `clear_thinking_20251015` edit type removes thinking/reasoning blocks from earlier turns, keeping only the most recent ones:
302
+
303
+ - **keep** - How many recent thinking turns to preserve (e.g., `{ type: 'thinking_turns', value: 2 }`) or `'all'` to keep everything
298
304
 
299
305
  ```ts
300
306
  const result = await generateText({
@@ -425,7 +431,6 @@ if (metadata?.appliedEdits) {
425
431
  console.log(`Freed ${edit.clearedInputTokens} tokens`);
426
432
  } else if (edit.type === 'compact_20260112') {
427
433
  console.log('Compaction was applied');
428
- console.log(`Freed ${edit.clearedInputTokens} tokens`);
429
434
  }
430
435
  });
431
436
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "3.0.46",
3
+ "version": "3.0.47",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -353,6 +353,9 @@ export class AnthropicMessagesLanguageModel implements LanguageModelV3 {
353
353
  ...(anthropicOptions?.speed && {
354
354
  speed: anthropicOptions.speed,
355
355
  }),
356
+ ...(anthropicOptions?.cacheControl && {
357
+ cache_control: anthropicOptions.cacheControl,
358
+ }),
356
359
 
357
360
  // structured output:
358
361
  ...(useStructuredOutput &&