ai 7.0.113 → 7.0.114

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +6 -6
  3. package/dist/index.js +64 -44
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/index.js +78 -51
  6. package/dist/internal/index.js.map +1 -1
  7. package/docs/02-foundations/02-providers-and-models.mdx +3 -0
  8. package/docs/02-foundations/03-prompts.mdx +1 -1
  9. package/docs/02-foundations/04-tools.mdx +2 -2
  10. package/docs/02-foundations/06-provider-options.mdx +11 -11
  11. package/docs/02-getting-started/00-choosing-a-provider.mdx +4 -4
  12. package/docs/02-getting-started/02-nextjs-app-router.mdx +3 -3
  13. package/docs/02-getting-started/03-nextjs-pages-router.mdx +3 -3
  14. package/docs/02-getting-started/04-svelte.mdx +7 -7
  15. package/docs/02-getting-started/05-nuxt.mdx +7 -7
  16. package/docs/02-getting-started/06-nodejs.mdx +3 -3
  17. package/docs/02-getting-started/07-expo.mdx +3 -3
  18. package/docs/02-getting-started/08-tanstack-start.mdx +3 -3
  19. package/docs/02-getting-started/09-coding-agents.mdx +1 -1
  20. package/docs/03-agents/03-workflows.mdx +2 -2
  21. package/docs/03-agents/04-loop-control.mdx +1 -1
  22. package/docs/03-agents/05-configuring-call-options.mdx +4 -2
  23. package/docs/03-agents/06-memory.mdx +2 -2
  24. package/docs/03-agents/06-policy-tool-approvals.mdx +2 -2
  25. package/docs/03-agents/07-workflow-agent.mdx +11 -11
  26. package/docs/03-agents/08-terminal-ui.mdx +2 -2
  27. package/docs/03-ai-sdk-core/05-generating-text.mdx +2 -2
  28. package/docs/03-ai-sdk-core/17-mcp-apps.mdx +1 -1
  29. package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +1 -1
  30. package/docs/03-ai-sdk-core/26-reasoning.mdx +13 -12
  31. package/docs/03-ai-sdk-core/31-reranking.mdx +12 -10
  32. package/docs/03-ai-sdk-core/32-evaluation.mdx +1 -1
  33. package/docs/03-ai-sdk-core/35-image-generation.mdx +2 -2
  34. package/docs/03-ai-sdk-core/37-speech.mdx +6 -6
  35. package/docs/03-ai-sdk-core/39-file-uploads.mdx +1 -1
  36. package/docs/03-ai-sdk-core/41-skill-uploads.mdx +1 -1
  37. package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
  38. package/docs/03-ai-sdk-core/45-provider-management.mdx +21 -21
  39. package/docs/03-ai-sdk-core/60-telemetry.mdx +1 -1
  40. package/docs/03-ai-sdk-core/65-devtools.mdx +3 -3
  41. package/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +1 -1
  42. package/docs/04-ai-sdk-ui/02-chatbot.mdx +3 -3
  43. package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +3 -3
  44. package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +1 -1
  45. package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +5 -5
  46. package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +1 -1
  47. package/docs/05-ai-sdk-rsc/06-loading-state.mdx +1 -1
  48. package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +3 -3
  49. package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +5 -3
  50. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +5 -3
  51. package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +5 -5
  52. package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +1 -1
  53. package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +2 -2
  54. package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +4 -2
  55. package/docs/07-reference/01-ai-sdk-core/20-start-batch.mdx +1 -1
  56. package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +1 -1
  57. package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +4 -4
  58. package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +1 -1
  59. package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +1 -1
  60. package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +3 -3
  61. package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +1 -1
  62. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +8 -8
  63. package/docs/07-reference/06-ai-sdk-tui/01-run-agent-tui.mdx +1 -1
  64. package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +3 -3
  65. package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
  66. package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +1 -1
  67. package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +2 -2
  68. package/package.json +6 -6
  69. package/src/evaluate/evaluate.ts +1 -10
  70. package/src/generate-text/restricted-telemetry-dispatcher.ts +6 -58
  71. package/src/prompt/standardize-prompt.ts +2 -0
  72. package/src/telemetry/create-telemetry-dispatcher.ts +58 -6
  73. package/src/telemetry/filter-included-context.ts +57 -2
@@ -40,7 +40,7 @@ To see `generateText` in action, check out [these examples](#examples).
40
40
  {
41
41
  name: 'model',
42
42
  type: 'LanguageModel',
43
- description: "The language model to use. Example: openai('gpt-4o')",
43
+ description: "The language model to use. Example: openai('gpt-6-astra')",
44
44
  },
45
45
  {
46
46
  name: 'instructions',
@@ -1117,7 +1117,8 @@ To see `generateText` in action, check out [these examples](#examples).
1117
1117
  {
1118
1118
  name: 'modelId',
1119
1119
  type: 'string',
1120
- description: 'The specific model identifier (e.g., "gpt-4o").',
1120
+ description:
1121
+ 'The specific model identifier (e.g., "gpt-6-astra").',
1121
1122
  },
1122
1123
  {
1123
1124
  name: 'instructions',
@@ -1269,7 +1270,8 @@ To see `generateText` in action, check out [these examples](#examples).
1269
1270
  {
1270
1271
  name: 'modelId',
1271
1272
  type: 'string',
1272
- description: 'The specific model identifier (e.g., "gpt-4o").',
1273
+ description:
1274
+ 'The specific model identifier (e.g., "gpt-6-astra").',
1273
1275
  },
1274
1276
  {
1275
1277
  name: 'instructions',
@@ -42,7 +42,7 @@ To see `streamText` in action, check out [these examples](#examples).
42
42
  {
43
43
  name: 'model',
44
44
  type: 'LanguageModel',
45
- description: "The language model to use. Example: openai('gpt-4.1')",
45
+ description: "The language model to use. Example: openai('gpt-6-astra')",
46
46
  },
47
47
  {
48
48
  name: 'instructions',
@@ -2131,7 +2131,8 @@ To see `streamText` in action, check out [these examples](#examples).
2131
2131
  {
2132
2132
  name: 'modelId',
2133
2133
  type: 'string',
2134
- description: 'The specific model identifier (e.g., "gpt-4o").',
2134
+ description:
2135
+ 'The specific model identifier (e.g., "gpt-6-astra").',
2135
2136
  },
2136
2137
  {
2137
2138
  name: 'instructions',
@@ -2283,7 +2284,8 @@ To see `streamText` in action, check out [these examples](#examples).
2283
2284
  {
2284
2285
  name: 'modelId',
2285
2286
  type: 'string',
2286
- description: 'The specific model identifier (e.g., "gpt-4o").',
2287
+ description:
2288
+ 'The specific model identifier (e.g., "gpt-6-astra").',
2287
2289
  },
2288
2290
  {
2289
2291
  name: 'instructions',
@@ -14,7 +14,7 @@ import { cohere } from '@ai-sdk/cohere';
14
14
  import { rerank } from 'ai';
15
15
 
16
16
  const { ranking } = await rerank({
17
- model: cohere.reranking('rerank-v3.5'),
17
+ model: cohere.reranking('rerank-v4.0-pro'),
18
18
  documents: ['sunny day at the beach', 'rainy afternoon in the city'],
19
19
  query: 'talk about rain',
20
20
  });
@@ -34,7 +34,7 @@ const { ranking } = await rerank({
34
34
  name: 'model',
35
35
  type: 'RerankingModel',
36
36
  description:
37
- "The reranking model to use. Example: cohere.reranking('rerank-v3.5')",
37
+ "The reranking model to use. Example: cohere.reranking('rerank-v4.0-pro')",
38
38
  },
39
39
  {
40
40
  name: 'documents',
@@ -262,7 +262,7 @@ import { cohere } from '@ai-sdk/cohere';
262
262
  import { rerank } from 'ai';
263
263
 
264
264
  const { ranking, rerankedDocuments } = await rerank({
265
- model: cohere.reranking('rerank-v3.5'),
265
+ model: cohere.reranking('rerank-v4.0-pro'),
266
266
  documents: [
267
267
  'sunny day at the beach',
268
268
  'rainy afternoon in the city',
@@ -302,7 +302,7 @@ const documents = [
302
302
  ];
303
303
 
304
304
  const { ranking } = await rerank({
305
- model: cohere.reranking('rerank-v3.5'),
305
+ model: cohere.reranking('rerank-v4.0-pro'),
306
306
  documents,
307
307
  query: 'Which pricing did we get from Oracle?',
308
308
  topN: 1,
@@ -319,7 +319,7 @@ import { cohere } from '@ai-sdk/cohere';
319
319
  import { rerank } from 'ai';
320
320
 
321
321
  const { ranking } = await rerank({
322
- model: cohere.reranking('rerank-v3.5'),
322
+ model: cohere.reranking('rerank-v4.0-pro'),
323
323
  documents: ['sunny day at the beach', 'rainy afternoon in the city'],
324
324
  query: 'talk about rain',
325
325
  providerOptions: {
@@ -13,7 +13,7 @@ import { openai } from '@ai-sdk/openai';
13
13
  import { readFile } from 'fs/promises';
14
14
 
15
15
  const { text: transcript } = await transcribe({
16
- model: openai.transcription('whisper-1'),
16
+ model: openai.transcription('gpt-4o-transcribe'),
17
17
  audio: await readFile('audio.mp3'),
18
18
  });
19
19
 
@@ -12,7 +12,7 @@ import { generateSpeech } from 'ai';
12
12
  import { openai } from '@ai-sdk/openai';
13
13
 
14
14
  const { audio } = await generateSpeech({
15
- model: openai.speech('tts-1'),
15
+ model: openai.speech('gpt-4o-mini-tts'),
16
16
  text: 'Hello from the AI SDK!',
17
17
  voice: 'alloy',
18
18
  });
@@ -29,7 +29,7 @@ import { generateSpeech } from 'ai';
29
29
  import { openai } from '@ai-sdk/openai';
30
30
 
31
31
  const { audio } = await generateSpeech({
32
- model: openai.speech('tts-1'),
32
+ model: openai.speech('gpt-4o-mini-tts'),
33
33
  text: 'Hello from the AI SDK!',
34
34
  voice: 'alloy',
35
35
  });
@@ -172,7 +172,8 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
172
172
  {
173
173
  name: 'modelId',
174
174
  type: 'string',
175
- description: 'The specific model identifier (e.g., "gpt-4o").',
175
+ description:
176
+ 'The specific model identifier (e.g., "gpt-6-astra").',
176
177
  },
177
178
  {
178
179
  name: 'instructions',
@@ -319,7 +320,8 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
319
320
  {
320
321
  name: 'modelId',
321
322
  type: 'string',
322
- description: 'The specific model identifier (e.g., "gpt-4o").',
323
+ description:
324
+ 'The specific model identifier (e.g., "gpt-6-astra").',
323
325
  },
324
326
  {
325
327
  name: 'instructions',
@@ -20,7 +20,7 @@ const batch = await startBatch({
20
20
  {
21
21
  id: 'france',
22
22
  type: 'text',
23
- model: 'gpt-4.1-nano',
23
+ model: 'gpt-5.4-nano',
24
24
  prompt: 'What is the capital of France?',
25
25
  },
26
26
  ],
@@ -62,7 +62,7 @@ import { generateText } from 'ai';
62
62
  import { registry } from './registry';
63
63
 
64
64
  const { text } = await generateText({
65
- model: registry.languageModel('openai:gpt-4.1'),
65
+ model: registry.languageModel('openai:gpt-6-astra'),
66
66
  prompt: 'Invent a new holiday and describe its traditions.',
67
67
  });
68
68
  ```
@@ -24,8 +24,8 @@ import { customProvider } from 'ai';
24
24
  export const myOpenAI = customProvider({
25
25
  languageModels: {
26
26
  // replacement model with custom settings:
27
- 'gpt-5': wrapLanguageModel({
28
- model: openai('gpt-5'),
27
+ 'gpt-6-astra': wrapLanguageModel({
28
+ model: openai('gpt-6-astra'),
29
29
  middleware: defaultSettingsMiddleware({
30
30
  settings: {
31
31
  providerOptions: {
@@ -37,8 +37,8 @@ export const myOpenAI = customProvider({
37
37
  }),
38
38
  }),
39
39
  // alias model with custom settings:
40
- 'gpt-4o-reasoning-high': wrapLanguageModel({
41
- model: openai('gpt-4o'),
40
+ 'gpt-6-astra-reasoning-high': wrapLanguageModel({
41
+ model: openai('gpt-6-astra'),
42
42
  middleware: defaultSettingsMiddleware({
43
43
  settings: {
44
44
  providerOptions: {
@@ -13,7 +13,7 @@ See [Language Model Middleware](/docs/ai-sdk-core/middleware) for more informati
13
13
  import { wrapLanguageModel, gateway } from 'ai';
14
14
 
15
15
  const wrappedLanguageModel = wrapLanguageModel({
16
- model: gateway('openai/gpt-4.1'),
16
+ model: gateway('openai/gpt-6-astra'),
17
17
  middleware: yourLanguageModelMiddleware,
18
18
  });
19
19
  ```
@@ -13,7 +13,7 @@ import { generateImage, wrapImageModel } from 'ai';
13
13
  import { openai } from '@ai-sdk/openai';
14
14
 
15
15
  const model = wrapImageModel({
16
- model: openai.image('gpt-image-2'),
16
+ model: openai.image('gpt-image-2.5-sunburst'),
17
17
  middleware: yourImageModelMiddleware,
18
18
  });
19
19
 
@@ -202,7 +202,7 @@ import { DirectChatTransport, ToolLoopAgent } from 'ai';
202
202
  import { openai } from '@ai-sdk/openai';
203
203
 
204
204
  const agent = new ToolLoopAgent({
205
- model: openai('gpt-4o'),
205
+ model: openai('gpt-6-astra'),
206
206
  instructions: 'You are a helpful assistant.',
207
207
  });
208
208
 
@@ -246,7 +246,7 @@ const weatherTool = tool({
246
246
  });
247
247
 
248
248
  const agent = new ToolLoopAgent({
249
- model: openai('gpt-4o'),
249
+ model: openai('gpt-6-astra'),
250
250
  instructions: 'You are a helpful assistant with access to weather data.',
251
251
  tools: { weather: weatherTool },
252
252
  });
@@ -268,7 +268,7 @@ import { DirectChatTransport, ToolLoopAgent } from 'ai';
268
268
  import { openai } from '@ai-sdk/openai';
269
269
 
270
270
  const agent = new ToolLoopAgent<{ userId: string }>({
271
- model: openai('gpt-4o'),
271
+ model: openai('gpt-6-astra'),
272
272
  prepareCall: ({ options, ...rest }) => ({
273
273
  ...rest,
274
274
  providerOptions: {
@@ -26,7 +26,7 @@ To see `streamUI` in action, check out [these examples](#examples).
26
26
  {
27
27
  name: 'model',
28
28
  type: 'LanguageModel',
29
- description: 'The language model to use. Example: openai("gpt-4.1")',
29
+ description: 'The language model to use. Example: openai("gpt-6-astra")',
30
30
  },
31
31
  {
32
32
  name: 'initial',
@@ -17,7 +17,7 @@ import { tool } from 'ai';
17
17
  import { z } from 'zod';
18
18
 
19
19
  const agent = new WorkflowAgent({
20
- model: 'anthropic/claude-sonnet-4-6',
20
+ model: 'anthropic/claude-sonnet-5',
21
21
  instructions: 'You are a helpful assistant.',
22
22
  tools: {
23
23
  weather: tool({
@@ -71,7 +71,7 @@ To see `WorkflowAgent` in action, check out [these examples](#examples).
71
71
  type: 'LanguageModel',
72
72
  isRequired: true,
73
73
  description:
74
- "The language model to use. A string compatible with the Vercel AI Gateway (e.g., 'anthropic/claude-sonnet-4-6') or a provider instance (e.g., `openai('gpt-4o')`).",
74
+ "The language model to use. A string compatible with the Vercel AI Gateway (e.g., 'anthropic/claude-sonnet-5') or a provider instance (e.g., `openai('gpt-6-astra')`).",
75
75
  },
76
76
  {
77
77
  name: 'instructions',
@@ -808,7 +808,7 @@ Infers the UI message type for a `WorkflowAgent` instance. Optionally accepts a
808
808
  import { WorkflowAgent, InferWorkflowAgentUIMessage } from '@ai-sdk/workflow';
809
809
 
810
810
  const agent = new WorkflowAgent({
811
- model: 'anthropic/claude-sonnet-4-6',
811
+ model: 'anthropic/claude-sonnet-5',
812
812
  tools: { weather: weatherTool },
813
813
  });
814
814
 
@@ -835,7 +835,7 @@ import { tool } from 'ai';
835
835
  import { z } from 'zod';
836
836
 
837
837
  const agent = new WorkflowAgent({
838
- model: 'anthropic/claude-sonnet-4-6',
838
+ model: 'anthropic/claude-sonnet-5',
839
839
  instructions: 'You are a helpful assistant.',
840
840
  tools: {
841
841
  weather: tool({
@@ -890,7 +890,7 @@ export async function chat(messages: UIMessage[]) {
890
890
  const modelMessages = await convertToModelMessages(messages);
891
891
 
892
892
  const agent = new WorkflowAgent({
893
- model: 'anthropic/claude-sonnet-4-6',
893
+ model: 'anthropic/claude-sonnet-5',
894
894
  instructions: 'You are a flight booking assistant.',
895
895
  tools: {
896
896
  searchFlights: tool({
@@ -937,7 +937,7 @@ import { WorkflowAgent, Output } from '@ai-sdk/workflow';
937
937
  import { z } from 'zod';
938
938
 
939
939
  const analysisAgent = new WorkflowAgent({
940
- model: 'anthropic/claude-sonnet-4-6',
940
+ model: 'anthropic/claude-sonnet-5',
941
941
  });
942
942
 
943
943
  const result = await analysisAgent.stream({
@@ -977,7 +977,7 @@ import { tool } from 'ai';
977
977
  import { z } from 'zod';
978
978
 
979
979
  const agent = new WorkflowAgent({
980
- model: 'anthropic/claude-sonnet-4-6',
980
+ model: 'anthropic/claude-sonnet-5',
981
981
  experimental_toolApprovalSecret: {
982
982
  environmentVariable: 'TOOL_APPROVAL_SECRET',
983
983
  },
@@ -1009,7 +1009,7 @@ serialize it. A stream-level reference overrides the constructor value.
1009
1009
  import { WorkflowAgent } from '@ai-sdk/workflow';
1010
1010
 
1011
1011
  const agent = new WorkflowAgent({
1012
- model: 'anthropic/claude-sonnet-4-6',
1012
+ model: 'anthropic/claude-sonnet-5',
1013
1013
  tools: { weather: weatherTool },
1014
1014
 
1015
1015
  // Agent-wide callbacks
@@ -17,7 +17,7 @@ import { runAgentTUI } from '@ai-sdk/tui';
17
17
  import { ToolLoopAgent } from 'ai';
18
18
 
19
19
  const agent = new ToolLoopAgent({
20
- model: openai('gpt-5'),
20
+ model: openai('gpt-6-astra'),
21
21
  instructions: 'You are a helpful terminal assistant.',
22
22
  });
23
23
 
@@ -73,7 +73,7 @@ const { messages, sendMessage } = useChat({
73
73
  'X-App-ID': 'my-app', // Static app identifier
74
74
  },
75
75
  body: {
76
- model: 'gpt-5.1', // Default model
76
+ model: 'gpt-6-astra', // Default model
77
77
  stream: true, // Static configuration
78
78
  },
79
79
  credentials: 'include', // Static credentials policy
@@ -125,7 +125,7 @@ const { messages, sendMessage } = useChat({
125
125
  'X-API-Version': 'v1',
126
126
  },
127
127
  body: {
128
- model: 'gpt-5.1',
128
+ model: 'gpt-6-astra',
129
129
  },
130
130
  }),
131
131
  });
@@ -139,7 +139,7 @@ sendMessage(
139
139
  'X-Request-ID': '123', // This is added
140
140
  },
141
141
  body: {
142
- model: 'gpt-5-mini', // This overrides the hook-level body field
142
+ model: 'gpt-4.1-mini', // Supports the temperature setting below
143
143
  temperature: 0.5, // This is added
144
144
  },
145
145
  },
@@ -15,7 +15,7 @@ export async function POST(req: Request) {
15
15
  const { messages } = await req.json();
16
16
 
17
17
  const result = streamText({
18
- model: 'openai/gpt-5-mini',
18
+ model: 'openai/gpt-6-luna',
19
19
  messages: await convertToModelMessages(messages),
20
20
  tools: {
21
21
  weather: {
@@ -49,7 +49,7 @@ export async function POST(req: Request) {
49
49
  const { messages } = await req.json();
50
50
 
51
51
  const result = streamText({
52
- model: 'openai/gpt-5-mini',
52
+ model: 'openai/gpt-6-luna',
53
53
  messages: await convertToModelMessages(messages),
54
54
  tools: {
55
55
  weather: {
@@ -128,7 +128,7 @@ export async function POST(req: Request) {
128
128
  const { messages, temperature, userId } = await req.json();
129
129
 
130
130
  const result = streamText({
131
- model: 'openai/gpt-5-mini',
131
+ model: 'openai/gpt-4.1-mini', // Supports dynamic temperature settings
132
132
  messages: await convertToModelMessages(messages),
133
133
  temperature, // Use the dynamic temperature from the request
134
134
  // ... other configuration
@@ -30,7 +30,7 @@ import { generateText } from 'ai';
30
30
  import { openai } from '@ai-sdk/openai';
31
31
 
32
32
  const result = await generateText({
33
- model: openai('gpt-4o'),
33
+ model: openai('gpt-6-astra'),
34
34
  messages: [
35
35
  {
36
36
  role: 'user',
@@ -85,7 +85,7 @@ const results = [];
85
85
 
86
86
  for (const imageUrl of imageUrls) {
87
87
  const result = await generateText({
88
- model: openai('gpt-4o'),
88
+ model: openai('gpt-6-astra'),
89
89
  messages: [
90
90
  {
91
91
  role: 'user',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.113",
3
+ "version": "7.0.114",
4
4
  "type": "module",
5
5
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
6
6
  "license": "Apache-2.0",
@@ -42,20 +42,20 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@ai-sdk/gateway": "4.0.91",
45
+ "@ai-sdk/gateway": "4.0.92",
46
46
  "@ai-sdk/provider": "4.0.18",
47
47
  "@ai-sdk/provider-utils": "5.0.47"
48
48
  },
49
49
  "devDependencies": {
50
- "@ai-sdk/amazon-bedrock": "5.0.93",
50
+ "@ai-sdk/amazon-bedrock": "5.0.94",
51
51
  "@ai-sdk/deepseek": "3.0.52",
52
- "@ai-sdk/google": "4.0.79",
52
+ "@ai-sdk/google": "4.0.80",
53
53
  "@ai-sdk/groq": "4.0.48",
54
54
  "@ai-sdk/huggingface": "2.0.55",
55
55
  "@ai-sdk/moonshotai": "3.0.56",
56
- "@ai-sdk/openai": "4.0.74",
56
+ "@ai-sdk/openai": "4.0.75",
57
57
  "@ai-sdk/test-server": "2.0.1",
58
- "@ai-sdk/xai": "5.0.7",
58
+ "@ai-sdk/xai": "5.0.8",
59
59
  "@edge-runtime/vm": "^5.0.0",
60
60
  "@smithy/eventstream-codec": "^4.3.3",
61
61
  "@smithy/util-utf8": "^4.3.3",
@@ -10,7 +10,6 @@ import {
10
10
  } from '@ai-sdk/provider-utils';
11
11
  import { resolveEvaluationModel } from '../model/resolve-model';
12
12
  import { logWarnings } from '../logger/log-warnings';
13
- import { filterIncludedContext } from '../telemetry/filter-included-context';
14
13
  import type { TelemetryOptions } from '../telemetry/telemetry-options';
15
14
  import type { Callback } from '../util/callback';
16
15
  import { notify } from '../util/notify';
@@ -112,17 +111,9 @@ export async function evaluate<
112
111
  headers,
113
112
  providerOptions,
114
113
  };
115
- const tracingStartEvent = {
116
- ...startEvent,
117
- runtimeContext: filterIncludedContext({
118
- context: runtimeContext,
119
- includeContext: telemetry?.includeRuntimeContext,
120
- }),
121
- };
122
-
123
114
  return await runInTracingChannelSpan({
124
115
  type: 'experimental_evaluate',
125
- event: tracingStartEvent,
116
+ event: startEvent,
126
117
  execute: async () => {
127
118
  await notify({
128
119
  event: startEvent,
@@ -1,10 +1,9 @@
1
- import type {
2
- Context,
3
- InferToolContext,
4
- InferToolSetContext,
5
- ToolSet,
6
- } from '@ai-sdk/provider-utils';
7
- import { filterIncludedContext } from '../telemetry/filter-included-context';
1
+ import type { Context, ToolSet } from '@ai-sdk/provider-utils';
2
+ import {
3
+ filterIncludedContext,
4
+ filterToolContext,
5
+ filterToolsContext,
6
+ } from '../telemetry/filter-included-context';
8
7
  import { createTelemetryDispatcher } from '../telemetry/create-telemetry-dispatcher';
9
8
  import type { TelemetryDispatcher } from '../telemetry/telemetry';
10
9
  import type {
@@ -98,57 +97,6 @@ function restrictStepResult<
98
97
  });
99
98
  }
100
99
 
101
- /**
102
- * Returns a shallow copy of the tools context with only top-level properties
103
- * marked for telemetry inclusion for each tool.
104
- */
105
- function filterToolsContext<TOOLS extends ToolSet>({
106
- toolsContext,
107
- includeToolsContext,
108
- }: {
109
- toolsContext: InferToolSetContext<TOOLS>;
110
- includeToolsContext: IncludedToolsContext<TOOLS>;
111
- }): InferToolSetContext<TOOLS> {
112
- if (includeToolsContext == null) {
113
- return {} as InferToolSetContext<TOOLS>;
114
- }
115
-
116
- return Object.fromEntries(
117
- Object.entries(toolsContext).map(([toolName, toolContext]) => [
118
- toolName,
119
- filterToolContext({
120
- toolName,
121
- toolContext,
122
- includeToolsContext,
123
- }),
124
- ]),
125
- ) as InferToolSetContext<TOOLS>;
126
- }
127
-
128
- function filterToolContext<TOOLS extends ToolSet>({
129
- toolName,
130
- toolContext,
131
- includeToolsContext,
132
- }: {
133
- toolName: string;
134
- toolContext: unknown;
135
- includeToolsContext: IncludedToolsContext<TOOLS>;
136
- }) {
137
- const includeToolContext = (
138
- includeToolsContext as
139
- | Record<
140
- string,
141
- IncludedContext<InferToolContext<TOOLS[typeof toolName]>>
142
- >
143
- | undefined
144
- )?.[toolName];
145
-
146
- return filterIncludedContext({
147
- context: toolContext as InferToolContext<TOOLS[typeof toolName]>,
148
- includeContext: includeToolContext,
149
- });
150
- }
151
-
152
100
  /**
153
101
  * Creates a telemetry dispatcher that only includes configured runtime context
154
102
  * properties in text-generation lifecycle events before dispatching them.
@@ -82,6 +82,8 @@ export async function standardizePrompt({
82
82
  });
83
83
  }
84
84
 
85
+ // Require explicit trust in supplied system messages to reduce prompt-injection
86
+ // risk. The opt-in permits all system messages, including instruction text.
85
87
  if (
86
88
  !allowSystemInMessages &&
87
89
  messages.some(message => message.role === 'system')
@@ -1,5 +1,10 @@
1
- import { asArray } from '@ai-sdk/provider-utils';
1
+ import { asArray, type Context } from '@ai-sdk/provider-utils';
2
2
  import type { Callback } from '../util/callback';
3
+ import {
4
+ filterIncludedContext,
5
+ filterToolContext,
6
+ filterToolsContext,
7
+ } from './filter-included-context';
3
8
  import { mergeCallbacks } from '../util/merge-callbacks';
4
9
  import type {
5
10
  InferTelemetryEvent,
@@ -41,14 +46,59 @@ function augmentEvent<EVENT>(
41
46
  event: EVENT,
42
47
  telemetry: Pick<
43
48
  TelemetryOptions,
44
- 'recordInputs' | 'recordOutputs' | 'functionId'
49
+ | 'recordInputs'
50
+ | 'recordOutputs'
51
+ | 'functionId'
52
+ | 'includeRuntimeContext'
53
+ | 'includeToolsContext'
45
54
  >,
55
+ filterContext = false,
46
56
  ): InferTelemetryEvent<EVENT> {
47
- return Object.assign(
57
+ const augmentedEvent = Object.assign(
48
58
  Object.create(Object.getPrototypeOf(event)),
49
59
  event,
50
- telemetry,
60
+ {
61
+ recordInputs: telemetry.recordInputs,
62
+ recordOutputs: telemetry.recordOutputs,
63
+ functionId: telemetry.functionId,
64
+ },
51
65
  );
66
+
67
+ if (
68
+ filterContext &&
69
+ event != null &&
70
+ typeof event === 'object' &&
71
+ 'runtimeContext' in event
72
+ ) {
73
+ augmentedEvent.runtimeContext = filterIncludedContext({
74
+ context: event.runtimeContext as Context,
75
+ includeContext: telemetry.includeRuntimeContext,
76
+ });
77
+ }
78
+
79
+ if (filterContext && event != null && typeof event === 'object') {
80
+ if ('toolsContext' in event) {
81
+ augmentedEvent.toolsContext = filterToolsContext({
82
+ toolsContext: event.toolsContext as Record<string, Context>,
83
+ includeToolsContext: telemetry.includeToolsContext,
84
+ });
85
+ } else if (
86
+ 'toolContext' in event &&
87
+ event.toolContext != null &&
88
+ 'toolCall' in event &&
89
+ event.toolCall != null &&
90
+ typeof event.toolCall === 'object' &&
91
+ 'toolName' in event.toolCall
92
+ ) {
93
+ augmentedEvent.toolContext = filterToolContext({
94
+ toolName: event.toolCall.toolName as string,
95
+ toolContext: event.toolContext,
96
+ includeToolsContext: telemetry.includeToolsContext,
97
+ });
98
+ }
99
+ }
100
+
101
+ return augmentedEvent;
52
102
  }
53
103
 
54
104
  /**
@@ -86,6 +136,8 @@ export function createTelemetryDispatcher({
86
136
  recordInputs: telemetry?.recordInputs,
87
137
  recordOutputs: telemetry?.recordOutputs,
88
138
  functionId: telemetry?.functionId,
139
+ includeRuntimeContext: telemetry?.includeRuntimeContext,
140
+ includeToolsContext: telemetry?.includeToolsContext,
89
141
  };
90
142
 
91
143
  const mergeTelemetryCallback = <KEY extends TelemetryCallbackKey>(
@@ -127,7 +179,7 @@ export function createTelemetryDispatcher({
127
179
  await runWithTracingChannelSpan(
128
180
  {
129
181
  type,
130
- event: augmentEvent(event, telemetryMetadata),
182
+ event: augmentEvent(event, telemetryMetadata, true),
131
183
  },
132
184
  execute,
133
185
  ),
@@ -136,7 +188,7 @@ export function createTelemetryDispatcher({
136
188
  openTelemetryChannelSpanContext({
137
189
  message: {
138
190
  type,
139
- event: augmentEvent(event, telemetryMetadata),
191
+ event: augmentEvent(event, telemetryMetadata, true),
140
192
  },
141
193
  completion,
142
194
  }),