@ai-sdk/workflow 1.0.51 → 1.0.54

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": "1.0.51",
3
+ "version": "1.0.54",
4
4
  "type": "module",
5
5
  "description": "WorkflowAgent for building AI agents with AI SDK",
6
6
  "license": "Apache-2.0",
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "ajv": "^8.20.0",
30
- "@ai-sdk/provider": "4.0.5",
31
- "@ai-sdk/provider-utils": "5.0.20",
32
- "ai": "7.0.51"
30
+ "@ai-sdk/provider-utils": "5.0.22",
31
+ "ai": "7.0.54",
32
+ "@ai-sdk/provider": "4.0.5"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "22.19.19",
@@ -2363,6 +2363,10 @@ export class WorkflowAgent<
2363
2363
  // Emit tool-approval-request chunks for tools that need approval
2364
2364
  // so useChat can show the approval UI
2365
2365
  if (options.writable) {
2366
+ if (allToolResults.length > 0) {
2367
+ await writeToolResults(options.writable, allToolResults);
2368
+ }
2369
+
2366
2370
  const approvalToolCalls = pausedToolCalls.filter((_, i) => {
2367
2371
  const tcIndex = nonProviderToolCalls.indexOf(
2368
2372
  pausedToolCalls[i],
@@ -2471,7 +2475,7 @@ export class WorkflowAgent<
2471
2475
  // UI can transition tool parts to output-available state and
2472
2476
  // properly separate multi-step model calls in the message history.
2473
2477
  if (options.writable) {
2474
- await writeToolResultsWithStepBoundary(
2478
+ await writeToolResults(
2475
2479
  options.writable,
2476
2480
  executedToolResults.map(r => ({
2477
2481
  toolCallId: r.modelResult.toolCallId,
@@ -2481,6 +2485,7 @@ export class WorkflowAgent<
2481
2485
  )?.input,
2482
2486
  output: r.rawOutput,
2483
2487
  })),
2488
+ true,
2484
2489
  );
2485
2490
  }
2486
2491
 
@@ -2695,7 +2700,7 @@ async function writeApprovalRequests(
2695
2700
  }
2696
2701
  }
2697
2702
 
2698
- async function writeToolResultsWithStepBoundary(
2703
+ async function writeToolResults(
2699
2704
  writable: WritableStream<any>,
2700
2705
  results: Array<{
2701
2706
  toolCallId: string;
@@ -2703,6 +2708,7 @@ async function writeToolResultsWithStepBoundary(
2703
2708
  input: unknown;
2704
2709
  output: unknown;
2705
2710
  }>,
2711
+ writeStepBoundary = false,
2706
2712
  ) {
2707
2713
  'use step';
2708
2714
  const writer = writable.getWriter();
@@ -2716,12 +2722,14 @@ async function writeToolResultsWithStepBoundary(
2716
2722
  output: r.output,
2717
2723
  });
2718
2724
  }
2719
- // Emit step boundaries so the UI message history properly separates
2720
- // the tool call step from the subsequent text step. This ensures
2721
- // convertToModelMessages creates separate assistant messages for
2722
- // tool calls and text responses.
2723
- await writer.write({ type: 'finish-step' });
2724
- await writer.write({ type: 'start-step' });
2725
+ if (writeStepBoundary) {
2726
+ // Emit step boundaries so the UI message history properly separates
2727
+ // the tool call step from the subsequent text step. This ensures
2728
+ // convertToModelMessages creates separate assistant messages for
2729
+ // tool calls and text responses.
2730
+ await writer.write({ type: 'finish-step' });
2731
+ await writer.write({ type: 'start-step' });
2732
+ }
2725
2733
  } finally {
2726
2734
  writer.releaseLock();
2727
2735
  }