ai 7.0.172 → 7.0.173
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 +22 -0
- package/dist/index.js +34 -21
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +98 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +53 -16
- package/dist/internal/index.js.map +1 -1
- package/docs/02-foundations/03-prompts.mdx +1 -1
- package/docs/03-agents/04-loop-control.mdx +1 -1
- package/docs/03-agents/06-tool-approvals.mdx +1 -1
- package/docs/03-agents/07-workflow-agent.mdx +87 -34
- package/docs/03-ai-sdk-core/05-generating-text.mdx +7 -2
- package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +4 -0
- package/docs/03-ai-sdk-core/16-mcp-tools.mdx +3 -0
- package/docs/03-ai-sdk-core/26-reasoning.mdx +3 -3
- package/docs/03-ai-sdk-core/32-decisions.mdx +4 -0
- package/docs/03-ai-sdk-core/33-extractions.mdx +1 -1
- package/docs/03-ai-sdk-core/35-image-generation.mdx +2 -0
- package/docs/03-ai-sdk-core/36-transcription.mdx +3 -0
- package/docs/03-ai-sdk-core/37-speech.mdx +3 -0
- package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +6 -0
- package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +3 -0
- package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +62 -5
- package/package.json +10 -10
- package/src/agent/default-stop-condition.ts +28 -13
- package/src/generate-text/validate-tool-approvals.ts +23 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.173
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3c09e00: Prevent in-place schema validation or input refinement from changing approved tool arguments during approval replay.
|
|
8
|
+
- f43ee39: fix(workflow): log the default step limit warning when `WorkflowAgent.generate()` stops at the default limit.
|
|
9
|
+
- 7ce7ffc: fix(workflow): log provider warnings in `WorkflowAgent`
|
|
10
|
+
|
|
11
|
+
`WorkflowAgent.generate()` and `WorkflowAgent.stream()` now log the warnings of every model call through the AI SDK warning logger, like `ToolLoopAgent`. The `AI_SDK_LOG_WARNINGS` global controls the output.
|
|
12
|
+
|
|
13
|
+
- f6809e3: fix(workflow): align the `prepareStep` results of `WorkflowAgent` with `ToolLoopAgent`. Returned `instructions` (or the deprecated `system`) replace the instructions of the step and carry forward to later steps, returned `providerOptions` are merged with the agent options, and returned `headers` are merged over the headers of the call.
|
|
14
|
+
- 2559173: feat(workflow): support `toolApproval` in `WorkflowAgent`
|
|
15
|
+
|
|
16
|
+
`WorkflowAgent` accepts a `toolApproval` configuration in the constructor and per `generate()` or `stream()` call. The configuration takes precedence over a tool's `needsApproval` setting, and its functions run in workflow context, outside of the durable model steps. Calls that the configuration approves run in the same step, and calls that it denies receive an `execution-denied` tool result without pausing the workflow.
|
|
17
|
+
|
|
18
|
+
- f1de9cb: feat(workflow): support the `timeout` object in `WorkflowAgent`
|
|
19
|
+
|
|
20
|
+
`generate()` and `stream()` accept `timeout: { totalMs, stepMs, firstChunkMs, chunkMs }` in addition to a number. `stepMs` limits each model call. In `stream()`, `firstChunkMs` and `chunkMs` limit the wait for model output. Invalid timeout values are rejected with an `InvalidArgumentError`. A timeout now also ends a model step when the provider stream ignores the abort signal.
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [9baa2d0]
|
|
23
|
+
- @ai-sdk/gateway@4.0.146
|
|
24
|
+
|
|
3
25
|
## 7.0.172
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1251,7 +1251,7 @@ function cloneValue(value, seen) {
|
|
|
1251
1251
|
}
|
|
1252
1252
|
//#endregion
|
|
1253
1253
|
//#region src/version.ts
|
|
1254
|
-
const VERSION = "7.0.
|
|
1254
|
+
const VERSION = "7.0.173";
|
|
1255
1255
|
//#endregion
|
|
1256
1256
|
//#region src/util/download/download.ts
|
|
1257
1257
|
/**
|
|
@@ -5379,22 +5379,25 @@ async function validateApprovedToolApprovals({ approvedToolApprovals, tools, too
|
|
|
5379
5379
|
});
|
|
5380
5380
|
}
|
|
5381
5381
|
if (isExecutableTool(tool) && tool.inputSchema != null) {
|
|
5382
|
-
const hasInputSchemaInput = Object.prototype.hasOwnProperty.call(approvalRequest, "inputSchemaInput");
|
|
5383
|
-
const validation = await safeValidateTypes({
|
|
5384
|
-
value: hasInputSchemaInput ? approvalRequest.inputSchemaInput : toolCall.input,
|
|
5385
|
-
schema: asSchema$1(tool.inputSchema)
|
|
5386
|
-
});
|
|
5387
5382
|
let validationError;
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
const
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
},
|
|
5395
|
-
refineToolInput
|
|
5383
|
+
try {
|
|
5384
|
+
const approvedInput = structuredClone(toolCall.input);
|
|
5385
|
+
const hasInputSchemaInput = Object.prototype.hasOwnProperty.call(approvalRequest, "inputSchemaInput");
|
|
5386
|
+
const validation = await safeValidateTypes({
|
|
5387
|
+
value: structuredClone(hasInputSchemaInput ? approvalRequest.inputSchemaInput : toolCall.input),
|
|
5388
|
+
schema: asSchema$1(tool.inputSchema)
|
|
5396
5389
|
});
|
|
5397
|
-
if (!
|
|
5390
|
+
if (!validation.success) validationError = validation.error;
|
|
5391
|
+
else {
|
|
5392
|
+
const revalidatedToolCall = await refineParsedToolCallInput({
|
|
5393
|
+
toolCall: {
|
|
5394
|
+
...toolCall,
|
|
5395
|
+
input: validation.value
|
|
5396
|
+
},
|
|
5397
|
+
refineToolInput
|
|
5398
|
+
});
|
|
5399
|
+
if (!isDeepEqualData(structuredClone(revalidatedToolCall.input), approvedInput)) validationError = /* @__PURE__ */ new Error("Approved tool input does not match the validated schema output.");
|
|
5400
|
+
}
|
|
5398
5401
|
} catch (error) {
|
|
5399
5402
|
validationError = error;
|
|
5400
5403
|
}
|
|
@@ -11171,6 +11174,19 @@ function isCausedByAbort(error) {
|
|
|
11171
11174
|
//#endregion
|
|
11172
11175
|
//#region src/agent/default-stop-condition.ts
|
|
11173
11176
|
/**
|
|
11177
|
+
* Logs the warning for the default stopWhen condition.
|
|
11178
|
+
*/
|
|
11179
|
+
function logDefaultStopConditionWarning({ stepCount, provider, modelId }) {
|
|
11180
|
+
logWarnings({
|
|
11181
|
+
provider,
|
|
11182
|
+
model: modelId,
|
|
11183
|
+
warnings: [{
|
|
11184
|
+
type: "other",
|
|
11185
|
+
message: `The tool loop stopped because it reached the default stopWhen condition, isStepCount(${stepCount}). To allow more steps, set stopWhen to isStepCount(...) with a higher limit or provide a custom stop condition. Learn more: https://ai-sdk.dev/docs/agents/loop-control`
|
|
11186
|
+
}]
|
|
11187
|
+
});
|
|
11188
|
+
}
|
|
11189
|
+
/**
|
|
11174
11190
|
* Stop conditions are only evaluated when the tool loop can otherwise continue,
|
|
11175
11191
|
* so logging here avoids warning when a call finishes naturally at the limit.
|
|
11176
11192
|
*/
|
|
@@ -11178,13 +11194,10 @@ function createDefaultStopCondition(stepCount) {
|
|
|
11178
11194
|
return ({ steps }) => {
|
|
11179
11195
|
if (steps.length !== stepCount) return false;
|
|
11180
11196
|
const { provider, modelId } = steps[steps.length - 1].model;
|
|
11181
|
-
|
|
11197
|
+
logDefaultStopConditionWarning({
|
|
11198
|
+
stepCount,
|
|
11182
11199
|
provider,
|
|
11183
|
-
|
|
11184
|
-
warnings: [{
|
|
11185
|
-
type: "other",
|
|
11186
|
-
message: `The tool loop stopped because it reached the default stopWhen condition, isStepCount(${stepCount}). To allow more steps, set stopWhen to isStepCount(...) with a higher limit or provide a custom stop condition. Learn more: https://ai-sdk.dev/docs/agents/loop-control`
|
|
11187
|
-
}]
|
|
11200
|
+
modelId
|
|
11188
11201
|
});
|
|
11189
11202
|
return true;
|
|
11190
11203
|
};
|