ai 6.0.187 → 6.0.188

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.
@@ -152,7 +152,7 @@ function detectMediaType({
152
152
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
153
153
 
154
154
  // src/version.ts
155
- var VERSION = true ? "6.0.187" : "0.0.0-test";
155
+ var VERSION = true ? "6.0.188" : "0.0.0-test";
156
156
 
157
157
  // src/util/download/download.ts
158
158
  var download = async ({
@@ -131,7 +131,7 @@ import {
131
131
  } from "@ai-sdk/provider-utils";
132
132
 
133
133
  // src/version.ts
134
- var VERSION = true ? "6.0.187" : "0.0.0-test";
134
+ var VERSION = true ? "6.0.188" : "0.0.0-test";
135
135
 
136
136
  // src/util/download/download.ts
137
137
  var download = async ({
@@ -55,6 +55,13 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
55
55
  description:
56
56
  'Instructions for the agent, usually used for system prompt/context.',
57
57
  },
58
+ {
59
+ name: 'allowSystemInMessages',
60
+ type: 'boolean',
61
+ isOptional: true,
62
+ description:
63
+ 'Whether `role: "system"` messages are allowed in the `prompt` or `messages` fields. When unset, system messages are rejected because they can create a prompt injection attack risk. Ideally, use the `instructions` option instead. Set to `true` to allow system messages, or `false` to explicitly reject them.',
64
+ },
58
65
  {
59
66
  name: 'tools',
60
67
  type: 'Record<string, Tool>',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "6.0.187",
3
+ "version": "6.0.188",
4
4
  "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.",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -48,6 +48,16 @@ export type ToolLoopAgentSettings<
48
48
  */
49
49
  instructions?: string | SystemModelMessage | Array<SystemModelMessage>;
50
50
 
51
+ /**
52
+ * Whether system messages are allowed in the `prompt` or `messages` fields.
53
+ *
54
+ * When disabled, system messages must be provided through the `instructions`
55
+ * option.
56
+ *
57
+ * @default false
58
+ */
59
+ allowSystemInMessages?: boolean;
60
+
51
61
  /**
52
62
  * The language model to use.
53
63
  */
@@ -161,6 +171,7 @@ export type ToolLoopAgentSettings<
161
171
  | 'seed'
162
172
  | 'headers'
163
173
  | 'instructions'
174
+ | 'allowSystemInMessages'
164
175
  | 'stopWhen'
165
176
  | 'experimental_telemetry'
166
177
  | 'activeTools'
@@ -183,6 +194,7 @@ export type ToolLoopAgentSettings<
183
194
  | 'seed'
184
195
  | 'headers'
185
196
  | 'instructions'
197
+ | 'allowSystemInMessages'
186
198
  | 'stopWhen'
187
199
  | 'experimental_telemetry'
188
200
  | 'activeTools'
@@ -63,7 +63,7 @@ export class ToolLoopAgent<
63
63
  }): Promise<
64
64
  Omit<
65
65
  ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>,
66
- 'prepareCall' | 'instructions' | 'onStepFinish'
66
+ 'prepareCall' | 'instructions' | 'allowSystemInMessages' | 'onStepFinish'
67
67
  > &
68
68
  Prompt
69
69
  > {
@@ -96,13 +96,24 @@ export class ToolLoopAgent<
96
96
  >[0],
97
97
  )) ?? baseCallArgs;
98
98
 
99
- const { instructions, messages, prompt, ...callArgs } = preparedCallArgs;
99
+ const {
100
+ instructions,
101
+ allowSystemInMessages,
102
+ messages,
103
+ prompt,
104
+ ...callArgs
105
+ } = preparedCallArgs;
100
106
 
101
107
  return {
102
108
  ...callArgs,
103
109
 
104
110
  // restore prompt types
105
- ...({ system: instructions, messages, prompt } as Prompt),
111
+ ...({
112
+ system: instructions,
113
+ allowSystemInMessages,
114
+ messages,
115
+ prompt,
116
+ } as Prompt),
106
117
  };
107
118
  }
108
119