@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.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +3 -0
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +3 -0
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +11 -6
- package/package.json +1 -1
- package/src/anthropic-messages-language-model.ts +3 -0
package/docs/05-anthropic.mdx
CHANGED
|
@@ -282,19 +282,25 @@ const result = await generateText({
|
|
|
282
282
|
console.log(result.providerMetadata?.anthropic?.contextManagement);
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
-
####
|
|
285
|
+
#### Context Editing
|
|
286
286
|
|
|
287
|
-
|
|
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
|
-
|
|
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
|
-
|
|
299
|
+
##### Clear Thinking
|
|
296
300
|
|
|
297
|
-
The `clear_thinking_20251015` edit type removes thinking/reasoning
|
|
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
|
@@ -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 &&
|