@ai-sdk/workflow 1.0.31 → 1.0.33

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.31",
3
+ "version": "1.0.33",
4
4
  "type": "module",
5
5
  "description": "WorkflowAgent for building AI agents with AI SDK",
6
6
  "license": "Apache-2.0",
@@ -28,8 +28,8 @@
28
28
  "dependencies": {
29
29
  "ajv": "^8.20.0",
30
30
  "@ai-sdk/provider": "4.0.3",
31
- "@ai-sdk/provider-utils": "5.0.11",
32
- "ai": "7.0.31"
31
+ "@ai-sdk/provider-utils": "5.0.12",
32
+ "ai": "7.0.33"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "22.19.19",
@@ -2,6 +2,7 @@ import type {
2
2
  LanguageModelV4CallOptions,
3
3
  LanguageModelV4Prompt,
4
4
  LanguageModelV4ToolResultPart,
5
+ SharedV4ProviderOptions,
5
6
  } from '@ai-sdk/provider';
6
7
  import type { Context } from '@ai-sdk/provider-utils';
7
8
  import {
@@ -391,27 +392,37 @@ export async function* streamTextIterator({
391
392
  if (finishReason === 'tool-calls') {
392
393
  lastStepWasToolCalls = true;
393
394
 
394
- // Add assistant message with tool calls to the conversation
395
+ const textContent = step.content.filter(
396
+ item => item.type === 'text',
397
+ ) as Array<{ type: 'text'; text: string }>;
398
+
399
+ // Add assistant message with text and tool calls to the conversation
395
400
  // Note: providerMetadata from the tool call is mapped to providerOptions
396
401
  // in the prompt format, following the AI SDK convention. This is critical
397
402
  // for providers like Gemini that require thoughtSignature to be preserved
398
403
  // across multi-turn tool calls. Some fields are sanitized before mapping.
399
404
  conversationPrompt.push({
400
405
  role: 'assistant',
401
- content: toolCalls.map(toolCall => {
402
- const sanitizedMetadata = sanitizeProviderMetadataForToolCall(
403
- toolCall.providerMetadata,
404
- );
405
- return {
406
- type: 'tool-call',
407
- toolCallId: toolCall.toolCallId,
408
- toolName: toolCall.toolName,
409
- input: toolCall.input,
410
- ...(sanitizedMetadata != null
411
- ? { providerOptions: sanitizedMetadata }
412
- : {}),
413
- };
414
- }) as typeof toolCalls,
406
+ content: [
407
+ ...textContent,
408
+ ...toolCalls.map(toolCall => {
409
+ const sanitizedMetadata = sanitizeProviderMetadataForToolCall(
410
+ toolCall.providerMetadata,
411
+ );
412
+ return {
413
+ type: 'tool-call' as const,
414
+ toolCallId: toolCall.toolCallId,
415
+ toolName: toolCall.toolName,
416
+ input: toolCall.input,
417
+ ...(sanitizedMetadata != null
418
+ ? {
419
+ providerOptions:
420
+ sanitizedMetadata as SharedV4ProviderOptions,
421
+ }
422
+ : {}),
423
+ };
424
+ }),
425
+ ],
415
426
  });
416
427
 
417
428
  // Yield the tool calls along with the current conversation messages