@ai-sdk/anthropic 3.0.77 → 3.0.78

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "3.0.77",
3
+ "version": "3.0.78",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -281,9 +281,19 @@ export async function convertToAnthropicMessagesPrompt({
281
281
  continue;
282
282
  }
283
283
 
284
+ const output = part.output;
285
+ const outputProviderOptions =
286
+ 'providerOptions' in output
287
+ ? output.providerOptions
288
+ : output.type === 'content'
289
+ ? output.value.find(
290
+ contentPart => contentPart.providerOptions != null,
291
+ )?.providerOptions
292
+ : undefined;
293
+
284
294
  // cache control: first add cache control from part.
285
- // for the last part of a message,
286
- // check also if the message has cache control.
295
+ // then from tool result output, and for the last part of a
296
+ // message, check also if the message has cache control.
287
297
  const isLastPart = i === content.length - 1;
288
298
 
289
299
  const cacheControl =
@@ -291,6 +301,10 @@ export async function convertToAnthropicMessagesPrompt({
291
301
  type: 'tool result part',
292
302
  canCache: true,
293
303
  }) ??
304
+ validator.getCacheControl(outputProviderOptions, {
305
+ type: 'tool result output',
306
+ canCache: true,
307
+ }) ??
294
308
  (isLastPart
295
309
  ? validator.getCacheControl(message.providerOptions, {
296
310
  type: 'tool result message',
@@ -298,7 +312,6 @@ export async function convertToAnthropicMessagesPrompt({
298
312
  })
299
313
  : undefined);
300
314
 
301
- const output = part.output;
302
315
  let contentValue: AnthropicToolResultContent['content'];
303
316
  switch (output.type) {
304
317
  case 'content':