Skip to content

Backport: fix(google): fix streaming tool call args#15442

Merged
aayush-kapoor merged 2 commits into
release-v6.0from
backport-pr-15438-to-release-v6.0
May 19, 2026
Merged

Backport: fix(google): fix streaming tool call args#15442
aayush-kapoor merged 2 commits into
release-v6.0from
backport-pr-15438-to-release-v6.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

This is an automated backport of #15438 to the release-v6.0 branch. FYI @aayush-kapoor

## Background

reported in #14358

the official feature docs mention that `willContinue` may be present and
marked as false or absent from the terminal chunk of the partial args
chunk that comes in.

the aisdk assumed that `willContinue` will ALWAYS be present.

that guard led to the tool call never actually forming and never
executing.

## Summary

adjusted the guard settings to properly form the tool call input args -
relaxed the guard on terminal chunk

## Manual Verification

verified by running the following repro; it doesn't fail before the fix
but rather you won't see any tool call object forming neither any
tool-result block. after the fix, the model executes it properly

<details>
<summary>repro:</summary>

```ts
import { googleVertex } from '@ai-sdk/google-vertex';
import { isStepCount, streamText, tool } from 'ai';
import { z } from 'zod';
import { run } from '../../lib/run';

run(async () => {
  const result = streamText({
    model: googleVertex('gemini-3-flash-preview'),
    prompt: 'List 2 fruits with prices. Use writeItems.',
    tools: {
      writeItems: tool({
        description: 'Write items',
        inputSchema: z.object({
          operations: z.array(
            z.object({
              action: z.enum(['add']),
              itemid: z.string(),
              description: z.string(),
              price: z.number(),
            }),
          ),
        }),
        execute: async ({ operations }) => {
          console.log('EXECUTE:', operations.length);
          return `${operations.length} items`;
        },
      }),
    },
    providerOptions: {
      vertex: {
        streamFunctionCallArguments: true,
      },
    },
    stopWhen: isStepCount(5),
  });

  for await (const part of result.fullStream) {
    switch (part.type) {
      case 'tool-input-start':
        console.log(`[tool-input-start] ${part.toolName} (${part.id})`);
        break;
      case 'tool-input-delta':
        process.stdout.write(part.delta);
        break;
      case 'tool-input-end':
        console.log(`\n[tool-input-end] (${part.id})`);
        break;
      case 'tool-call':
        console.log(`\n[tool-call] ${part.toolName}:`, part.input);
        break;
      case 'tool-result':
        console.log(`\n[tool-result] ${part.toolName}:`, part.output);
        break;
      case 'finish-step':
        console.log('\n[finish-step]', part.finishReason);
        break;
      case 'finish':
        console.log('[finish]', part.finishReason);
        break;
      case 'error':
        console.error('Error:', part.error);
        break;
    }
  }
});
```

</details>

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)

## Future Work

explore the reproduction if provided from this comment:
#14358 (comment)

remains a separate bug

## Related Issues

fixes #14358
auto-merge was automatically disabled May 19, 2026 18:22

Pull request was closed

@aayush-kapoor aayush-kapoor reopened this May 19, 2026
@aayush-kapoor aayush-kapoor enabled auto-merge (squash) May 19, 2026 18:22
@aayush-kapoor aayush-kapoor merged commit f259bd1 into release-v6.0 May 19, 2026
17 checks passed
@aayush-kapoor aayush-kapoor deleted the backport-pr-15438-to-release-v6.0 branch May 19, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant