@ai-sdk/workflow 2.0.18 → 2.0.19

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/workflow",
3
- "version": "2.0.18",
3
+ "version": "2.0.19",
4
4
  "type": "module",
5
5
  "description": "WorkflowAgent for building AI agents with AI SDK",
6
6
  "license": "Apache-2.0",
@@ -31,9 +31,9 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@ai-sdk/provider": "4.0.9",
35
- "@ai-sdk/provider-utils": "5.0.34",
36
- "ai": "7.0.88",
34
+ "@ai-sdk/provider": "4.0.10",
35
+ "@ai-sdk/provider-utils": "5.0.35",
36
+ "ai": "7.0.89",
37
37
  "ajv": "^8.20.0"
38
38
  },
39
39
  "devDependencies": {
@@ -298,7 +298,7 @@ export async function* streamTextIterator({
298
298
  try {
299
299
  // Filter tools if activeTools is specified
300
300
  const effectiveTools =
301
- currentActiveTools && currentActiveTools.length > 0
301
+ currentActiveTools !== undefined
302
302
  ? (filterActiveTools({
303
303
  tools,
304
304
  activeTools: currentActiveTools,
@@ -41,6 +41,7 @@ import {
41
41
  createRestrictedTelemetryDispatcher,
42
42
  collectToolApprovals,
43
43
  convertToLanguageModelPrompt,
44
+ mergeAbortSignals,
44
45
  mergeCallbacks,
45
46
  signToolApproval,
46
47
  standardizePrompt,
@@ -1552,6 +1553,12 @@ export class WorkflowAgent<
1552
1553
  } as Prompt);
1553
1554
  const download = effectiveDownloadFromPrepare;
1554
1555
  const sandbox = options.experimental_sandbox ?? this.experimentalSandbox;
1556
+ const effectiveAbortSignal = mergeAbortSignals(
1557
+ options.abortSignal ?? effectiveGenerationSettings.abortSignal,
1558
+ options.timeout,
1559
+ );
1560
+ const timeoutAt =
1561
+ options.timeout == null ? undefined : Date.now() + options.timeout;
1555
1562
  const mergedOnToolExecutionStart = mergeCallbacks(
1556
1563
  this.constructorOnToolExecutionStart,
1557
1564
  options.onToolExecutionStart,
@@ -1811,11 +1818,6 @@ export class WorkflowAgent<
1811
1818
  download,
1812
1819
  });
1813
1820
 
1814
- const effectiveAbortSignal =
1815
- options.abortSignal ?? effectiveGenerationSettings.abortSignal;
1816
- const timeoutAt =
1817
- options.timeout == null ? undefined : Date.now() + options.timeout;
1818
-
1819
1821
  // Merge generation settings: constructor defaults < prepareCall < stream options
1820
1822
  const mergedGenerationSettings: GenerationSettings = {
1821
1823
  ...effectiveGenerationSettings,
@@ -1889,7 +1891,7 @@ export class WorkflowAgent<
1889
1891
  // Filter tools if activeTools is specified (stream-level overrides constructor default)
1890
1892
  const effectiveActiveTools = effectiveActiveToolsFromPrepare;
1891
1893
  const effectiveTools =
1892
- effectiveActiveTools && effectiveActiveTools.length > 0
1894
+ effectiveActiveTools !== undefined
1893
1895
  ? (filterActiveTools({
1894
1896
  tools: this.tools,
1895
1897
  activeTools: effectiveActiveTools,
@@ -1999,6 +2001,7 @@ export class WorkflowAgent<
1999
2001
  tools,
2000
2002
  messages,
2001
2003
  resolvedContext,
2004
+ effectiveAbortSignal,
2002
2005
  download,
2003
2006
  stepSandbox,
2004
2007
  );
@@ -3099,6 +3102,7 @@ async function executeTool(
3099
3102
  tools: ToolSet,
3100
3103
  messages: LanguageModelV4Prompt,
3101
3104
  context?: unknown,
3105
+ abortSignal?: AbortSignal,
3102
3106
  download?: DownloadFunction,
3103
3107
  sandbox?: SandboxSession,
3104
3108
  ): Promise<WorkflowToolExecutionResult> {
@@ -3125,6 +3129,8 @@ async function executeTool(
3125
3129
  toolCallId: toolCall.toolCallId,
3126
3130
  // Pass the conversation messages to the tool so it has context about the conversation
3127
3131
  messages,
3132
+ // Pass the effective agent signal so in-flight tool work can cooperatively cancel
3133
+ abortSignal,
3128
3134
  // Pass per-tool context to the tool (resolved from `toolsContext`)
3129
3135
  context,
3130
3136
  experimental_sandbox: sandbox,