⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@pranaygp
Copy link
Collaborator

@pranaygp pranaygp commented Jan 7, 2026

Summary

This PR fixes issue #628 - provider-executed tools (tools with providerExecuted: true) now work correctly with the Workflow DevKit.

Problem

Provider-executed tools (like Google's googleSearch, Claude's WebSearch, OpenAI's web search tools, etc.) were causing errors because:

  1. The tool calls came from the model with providerExecuted: true
  2. The DurableAgent tried to execute them locally
  3. Since these tools aren't in the user's tools map, execution failed with "Tool not found" errors

Solution

The fix modifies three files in the @workflow/ai package:

do-stream-step.ts

  • Now captures tool-result stream parts that have providerExecuted: true
  • Stores these results in a Map<string, ProviderExecutedToolResult> keyed by toolCallId
  • Returns this map alongside the tool calls

stream-text-iterator.ts

  • Added ProviderExecutedToolResult interface
  • Updated StreamTextIteratorYieldValue to include providerExecutedToolResults
  • Passes the provider-executed tool results through to the agent

durable-agent.ts

  • Now separates tool calls into clientToolCalls (no providerExecuted flag) and providerToolCalls (providerExecuted: true)
  • Only executes clientToolCalls locally
  • For providerToolCalls, uses the results captured from the stream
  • Combines both sets of results in the original order before passing to the iterator

Testing

Added two new tests:

  1. should skip local execution for provider-executed tools - verifies provider-executed tools are NOT executed locally
  2. should handle mixed provider-executed and local tools - verifies mixed scenarios work correctly

All 64 tests pass.

Affected Providers

This fix enables proper support for:

  • @ai-sdk/google with google.tools.googleSearch()
  • @ai-sdk/openai with web search tools
  • ai-sdk-provider-claude-code (Claude Code's Bash, Read, Write, WebSearch, etc.)
  • Any MCP-based tools with providerExecuted: true

Fixes #628
Fixes #433
Closes #434 (duplicate)

Provider-executed tools (like Google's googleSearch, Claude's WebSearch, etc.)
have providerExecuted: true on their tool calls and should NOT be executed
locally. Instead, their results come from the provider via tool-result stream
parts.

This fix:
- Captures provider-executed tool results from the stream in do-stream-step.ts
- Passes these results through the iterator to the DurableAgent
- Separates client-executed from provider-executed tool calls
- Uses stream results for provider-executed tools instead of local execution
- Adds tests for provider-executed tools and mixed scenarios

Fixes #628
Copilot AI review requested due to automatic review settings January 7, 2026 07:04
@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2026

🦋 Changeset detected

Latest commit: 7851c7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@workflow/ai Patch
@workflow/docs-typecheck Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jan 7, 2026 7:07am
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jan 7, 2026 7:07am
example-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-astro-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-express-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-fastify-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-hono-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-nitro-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-nuxt-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-sveltekit-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workbench-vite-workflow Ready Ready Preview, Comment Jan 7, 2026 7:07am
workflow-docs Ready Ready Preview, Comment Jan 7, 2026 7:07am

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 363 0 11 374
✅ 💻 Local Development 332 0 8 340
✅ 📦 Local Production 332 0 8 340
✅ 🐘 Local Postgres 332 0 8 340
✅ 🪟 Windows 34 0 0 34
❌ 🌍 Community Worlds 131 17 0 148
Total 1524 17 35 1576

❌ Failed Tests

🌍 Community Worlds (17 failed)

mongodb (1 failed):

  • webhookWorkflow

redis (1 failed):

  • webhookWorkflow

starter (14 failed):

  • addTenWorkflow
  • addTenWorkflow
  • error handling error propagation workflow errors nested function calls preserve message and stack trace
  • error handling error propagation workflow errors cross-file imports preserve message and stack trace
  • error handling error propagation step errors basic step error preserves message and stack trace
  • error handling error propagation step errors cross-file step error preserves message and function names in stack
  • error handling retry behavior regular Error retries until success
  • error handling retry behavior FatalError fails immediately without retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly

turso (1 failed):

  • webhookWorkflow

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 33 0 1
✅ example 33 0 1
✅ express 33 0 1
✅ fastify 33 0 1
✅ hono 33 0 1
✅ nextjs-turbopack 33 0 1
✅ nextjs-webpack 33 0 1
✅ nitro 33 0 1
✅ nuxt 33 0 1
✅ sveltekit 33 0 1
✅ vite 33 0 1
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 33 0 1
✅ express-stable 33 0 1
✅ fastify-stable 33 0 1
✅ hono-stable 33 0 1
✅ nextjs-turbopack-stable 34 0 0
✅ nextjs-webpack-stable 34 0 0
✅ nitro-stable 33 0 1
✅ nuxt-stable 33 0 1
✅ sveltekit-stable 33 0 1
✅ vite-stable 33 0 1
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 33 0 1
✅ express-stable 33 0 1
✅ fastify-stable 33 0 1
✅ hono-stable 33 0 1
✅ nextjs-turbopack-stable 34 0 0
✅ nextjs-webpack-stable 34 0 0
✅ nitro-stable 33 0 1
✅ nuxt-stable 33 0 1
✅ sveltekit-stable 33 0 1
✅ vite-stable 33 0 1
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 33 0 1
✅ express-stable 33 0 1
✅ fastify-stable 33 0 1
✅ hono-stable 33 0 1
✅ nextjs-turbopack-stable 34 0 0
✅ nextjs-webpack-stable 34 0 0
✅ nitro-stable 33 0 1
✅ nuxt-stable 33 0 1
✅ sveltekit-stable 33 0 1
✅ vite-stable 33 0 1
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 34 0 0
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 3 0 0
❌ mongodb 33 1 0
✅ redis-dev 3 0 0
❌ redis 33 1 0
✅ starter-dev 3 0 0
❌ starter 20 14 0
✅ turso-dev 3 0 0
❌ turso 33 1 0

📋 View full workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Starter 🥇 Next.js (Turbopack) 0.039s (+2.9%) 1.014s (~) 0.975s 10 1.00x
🌐 Redis Next.js (Turbopack) 0.040s (-4.8%) 1.018s (~) 0.978s 10 1.03x
💻 Local Next.js (Turbopack) 0.043s (+23.6% 🔺) 1.016s (~) 0.973s 10 1.11x
💻 Local Express 0.045s (+0.9%) 1.007s (~) 0.962s 10 1.15x
💻 Local Nitro 0.047s (-3.9%) 1.006s (-0.7%) 0.959s 10 1.21x
🌐 Turso Next.js (Turbopack) 0.098s (+16.8% 🔺) 1.014s (~) 0.916s 10 2.53x
🌐 MongoDB Next.js (Turbopack) 0.131s (+10.8% 🔺) 1.014s (~) 0.883s 10 3.39x
🐘 Postgres Nitro 0.258s (-13.0% 🟢) 1.013s (~) 0.755s 10 6.66x
🐘 Postgres Express 0.279s (-19.0% 🟢) 1.014s (~) 0.735s 10 7.20x
🐘 Postgres Next.js (Turbopack) 0.309s (+103.4% 🔺) 1.020s (~) 0.711s 10 7.99x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 0.556s (-18.4% 🟢) 1.500s (-10.6% 🟢) 0.943s 10 1.00x
▲ Vercel Express 0.556s (-14.5% 🟢) 1.486s (-12.6% 🟢) 0.930s 10 1.00x
▲ Vercel Next.js (Turbopack) 0.615s (-18.1% 🟢) 1.531s (-9.9% 🟢) 0.916s 10 1.10x

🔍 Observability: Nitro | Express | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 1.088s (+0.6%) 2.011s (~) 0.923s 10 1.00x
🌐 Starter Next.js (Turbopack) 1.089s (+0.8%) 2.009s (~) 0.920s 10 1.00x
🌐 Redis Next.js (Turbopack) 1.104s (~) 2.013s (~) 0.909s 10 1.01x
💻 Local Nitro 1.114s (~) 2.006s (~) 0.892s 10 1.02x
💻 Local Express 1.114s (~) 2.006s (~) 0.892s 10 1.02x
🌐 Turso Next.js (Turbopack) 1.296s (~) 2.012s (~) 0.717s 10 1.19x
🌐 MongoDB Next.js (Turbopack) 1.298s (~) 2.014s (~) 0.715s 10 1.19x
🐘 Postgres Next.js (Turbopack) 1.629s (-12.6% 🟢) 2.017s (~) 0.388s 10 1.50x
🐘 Postgres Express 2.132s (-3.0%) 3.015s (~) 0.883s 10 1.96x
🐘 Postgres Nitro 2.196s (+1.9%) 3.016s (~) 0.820s 10 2.02x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.756s (-10.2% 🟢) 3.765s (-4.1%) 1.009s 10 1.00x
▲ Vercel Nitro 2.790s (-5.8% 🟢) 3.657s (-2.0%) 0.867s 10 1.01x
▲ Vercel Express 2.884s (-9.0% 🟢) 3.671s (-12.0% 🟢) 0.787s 10 1.05x

🔍 Observability: Next.js (Turbopack) | Nitro | Express

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Starter 🥇 Next.js (Turbopack) 10.599s (~) 11.010s (~) 0.411s 5 1.00x
💻 Local Next.js (Turbopack) 10.660s (+1.5%) 11.018s (~) 0.358s 5 1.01x
🌐 Redis Next.js (Turbopack) 10.676s (~) 11.016s (~) 0.340s 5 1.01x
💻 Local Nitro 10.795s (~) 11.013s (~) 0.218s 5 1.02x
💻 Local Express 10.801s (~) 11.013s (~) 0.211s 5 1.02x
🌐 MongoDB Next.js (Turbopack) 12.205s (~) 13.024s (~) 0.819s 5 1.15x
🌐 Turso Next.js (Turbopack) 12.227s (~) 13.026s (~) 0.800s 5 1.15x
🐘 Postgres Next.js (Turbopack) 15.358s (+0.9%) 15.839s (-1.2%) 0.481s 5 1.45x
🐘 Postgres Nitro 20.424s (~) 21.037s (~) 0.613s 5 1.93x
🐘 Postgres Express 20.497s (~) 21.028s (~) 0.531s 5 1.93x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 22.166s (-0.6%) 23.124s (~) 0.957s 5 1.00x
▲ Vercel Nitro 22.672s (+3.4%) 23.479s (+3.7%) 0.807s 5 1.02x
▲ Vercel Express 22.842s (+2.0%) 23.514s (~) 0.673s 5 1.03x

🔍 Observability: Next.js (Turbopack) | Nitro | Express

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Starter 🥇 Next.js (Turbopack) 1.356s (+1.0%) 2.008s (~) 0.652s 15 1.00x
🌐 Redis Next.js (Turbopack) 1.359s (~) 2.010s (~) 0.651s 15 1.00x
💻 Local Next.js (Turbopack) 1.380s (+3.3%) 2.012s (~) 0.631s 15 1.02x
💻 Local Express 1.415s (+0.8%) 2.007s (~) 0.591s 15 1.04x
💻 Local Nitro 1.422s (+0.8%) 2.005s (~) 0.583s 15 1.05x
🐘 Postgres Next.js (Turbopack) 1.768s (-8.1% 🟢) 2.165s (~) 0.397s 14 1.30x
🌐 MongoDB Next.js (Turbopack) 2.135s (+0.8%) 3.013s (~) 0.878s 10 1.57x
🌐 Turso Next.js (Turbopack) 2.184s (-1.8%) 3.012s (~) 0.829s 10 1.61x
🐘 Postgres Express 2.429s (~) 3.011s (~) 0.583s 10 1.79x
🐘 Postgres Nitro 2.518s (+6.3% 🔺) 3.015s (~) 0.497s 10 1.86x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.867s (-19.3% 🟢) 3.758s (-13.7% 🟢) 0.891s 8 1.00x
▲ Vercel Nitro 2.957s (-12.9% 🟢) 3.806s (-12.3% 🟢) 0.849s 8 1.03x
▲ Vercel Express 3.267s (+15.3% 🔺) 4.072s (+2.8%) 0.805s 8 1.14x

🔍 Observability: Next.js (Turbopack) | Nitro | Express

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 2.146s (+7.5% 🔺) 3.121s (+44.4% 🔺) 0.975s 10 1.00x
💻 Local Nitro 2.182s (~) 3.040s (-2.9%) 0.858s 10 1.02x
💻 Local Express 2.187s (-1.6%) 3.150s (-0.8%) 0.964s 10 1.02x
🌐 Starter Next.js (Turbopack) 2.455s (~) 3.008s (~) 0.553s 10 1.14x
🌐 Redis Next.js (Turbopack) 2.481s (~) 3.011s (~) 0.530s 10 1.16x
🐘 Postgres Next.js (Turbopack) 2.484s (-1.6%) 3.019s (~) 0.535s 10 1.16x
🐘 Postgres Express 2.844s (-1.9%) 3.012s (-3.2%) 0.169s 10 1.33x
🐘 Postgres Nitro 3.031s (+8.6% 🔺) 3.361s (+10.9% 🔺) 0.330s 9 1.41x
🌐 MongoDB Next.js (Turbopack) 4.783s (+3.3%) 5.181s (~) 0.398s 6 2.23x
🌐 Turso Next.js (Turbopack) 4.805s (+1.8%) 5.183s (~) 0.378s 6 2.24x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 3.392s (-0.7%) 4.031s (-1.7%) 0.639s 8 1.00x
▲ Vercel Express 3.551s (+7.9% 🔺) 4.467s (+10.4% 🔺) 0.916s 7 1.05x
▲ Vercel Nitro 3.630s (+22.1% 🔺) 4.480s (+24.6% 🔺) 0.851s 7 1.07x

🔍 Observability: Next.js (Turbopack) | Express | Nitro

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Starter 🥇 Next.js (Turbopack) 1.334s (-1.7%) 2.007s (~) 0.673s 15 1.00x
🌐 Redis Next.js (Turbopack) 1.344s (-0.9%) 2.009s (~) 0.666s 15 1.01x
💻 Local Next.js (Turbopack) 1.394s (+2.7%) 2.012s (~) 0.617s 15 1.05x
💻 Local Nitro 1.419s (+0.6%) 2.005s (~) 0.586s 15 1.06x
💻 Local Express 1.423s (~) 2.007s (~) 0.584s 15 1.07x
🐘 Postgres Next.js (Turbopack) 1.699s (-4.6%) 2.014s (~) 0.315s 15 1.27x
🐘 Postgres Nitro 2.180s (+19.1% 🔺) 2.829s (+40.8% 🔺) 0.649s 11 1.63x
🌐 MongoDB Next.js (Turbopack) 2.180s (+1.7%) 3.013s (~) 0.833s 10 1.63x
🌐 Turso Next.js (Turbopack) 2.232s (+0.6%) 3.014s (~) 0.783s 10 1.67x
🐘 Postgres Express 2.398s (+5.9% 🔺) 3.020s (~) 0.621s 10 1.80x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.705s (-2.2%) 3.604s (+0.6%) 0.899s 9 1.00x
▲ Vercel Next.js (Turbopack) 2.713s (-2.5%) 3.757s (+1.3%) 1.044s 8 1.00x
▲ Vercel Express 2.999s (+5.5% 🔺) 3.892s (+1.2%) 0.893s 9 1.11x

🔍 Observability: Nitro | Next.js (Turbopack) | Express

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 2.198s (+6.7% 🔺) 3.112s (+17.6% 🔺) 0.914s 10 1.00x
💻 Local Nitro 2.212s (~) 3.150s (~) 0.938s 10 1.01x
💻 Local Express 2.237s (-1.8%) 3.177s (-1.0%) 0.939s 10 1.02x
🌐 Redis Next.js (Turbopack) 2.450s (-1.1%) 3.011s (~) 0.561s 10 1.11x
🌐 Starter Next.js (Turbopack) 2.456s (~) 3.009s (~) 0.553s 10 1.12x
🐘 Postgres Next.js (Turbopack) 2.517s (+3.6%) 3.022s (~) 0.505s 10 1.15x
🐘 Postgres Express 2.805s (-2.3%) 3.014s (~) 0.208s 10 1.28x
🐘 Postgres Nitro 2.815s (+12.7% 🔺) 3.126s (+3.7%) 0.311s 10 1.28x
🌐 MongoDB Next.js (Turbopack) 4.623s (-1.2%) 5.181s (~) 0.558s 6 2.10x
🌐 Turso Next.js (Turbopack) 4.637s (-2.6%) 5.185s (~) 0.548s 6 2.11x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 3.425s (+5.7% 🔺) 4.147s (+7.8% 🔺) 0.722s 8 1.00x
▲ Vercel Nitro 3.446s (+8.2% 🔺) 3.887s (+5.8% 🔺) 0.441s 8 1.01x
▲ Vercel Express 4.098s (+27.7% 🔺) 4.644s (+21.2% 🔺) 0.546s 7 1.20x

🔍 Observability: Next.js (Turbopack) | Nitro | Express

Stream Benchmarks (includes TTFB metrics)
workflow with stream

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
🌐 Starter 🥇 Next.js (Turbopack) 0.126s (-2.0%) 1.006s (~) 0.000s (+Infinity% 🔺) 1.011s (~) 0.885s 10 1.00x
💻 Local Next.js (Turbopack) 0.136s (+34.7% 🔺) 1.003s (~) 0.017s (+1.2%) 1.027s (~) 0.891s 10 1.08x
🌐 Redis Next.js (Turbopack) 0.140s (-2.8%) 1.005s (~) 0.000s (NaN%) 1.013s (~) 0.873s 10 1.11x
💻 Local Express 0.176s (~) 0.993s (~) 0.016s (-1.8%) 1.023s (~) 0.847s 10 1.40x
💻 Local Nitro 0.180s (+3.2%) 0.993s (~) 0.016s (+4.6%) 1.022s (~) 0.842s 10 1.43x
🌐 Turso Next.js (Turbopack) 0.519s (+2.5%) 0.937s (-0.9%) 0.000s (+Infinity% 🔺) 1.015s (~) 0.496s 10 4.12x
🌐 MongoDB Next.js (Turbopack) 0.525s (+12.1% 🔺) 0.926s (-5.5% 🟢) 0.000s (NaN%) 1.013s (~) 0.488s 10 4.17x
🐘 Postgres Next.js (Turbopack) 0.872s (-26.5% 🟢) 1.030s (-44.7% 🟢) 0.000s (+Infinity% 🔺) 1.216s (-39.8% 🟢) 0.344s 10 6.93x
🐘 Postgres Nitro 2.191s (-5.1% 🟢) 2.853s (+4.4%) 0.000s (+Infinity% 🔺) 3.016s (~) 0.825s 10 17.40x
🐘 Postgres Express 2.321s (-1.5%) 2.720s (+1.3%) 0.000s (NaN%) 3.014s (~) 0.693s 10 18.44x

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.732s (-12.9% 🟢) 3.130s (-15.0% 🟢) 0.596s (-32.5% 🟢) 4.148s (-16.2% 🟢) 1.416s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.792s (-0.5%) 3.307s (+4.4%) 0.475s (-27.2% 🟢) 4.220s (-1.4%) 1.429s 10 1.02x
▲ Vercel Express 2.980s (+6.7% 🔺) 3.312s (~) 0.469s (+45.3% 🔺) 4.244s (+2.8%) 1.264s 10 1.09x

🔍 Observability: Nitro | Next.js (Turbopack) | Express

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World 🥇 Fastest Framework Wins
💻 Local Next.js (Turbopack) 8/8
🐘 Postgres Next.js (Turbopack) 7/8
▲ Vercel Next.js (Turbopack) 5/8
Fastest World by Framework

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 💻 Local 8/8
Next.js (Turbopack) 🌐 Starter 5/8
Nitro 💻 Local 8/8
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Starter: Community world (local development)
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for provider-executed tools in AI SDK v6 by preventing local execution of tools marked with providerExecuted: true and instead using results captured directly from the provider's stream.

Key Changes

  • Captures provider-executed tool results from the stream rather than attempting local execution
  • Separates tool calls into client-executed and provider-executed categories for proper handling
  • Adds comprehensive test coverage for both pure provider-executed and mixed tool scenarios

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

File Description
packages/ai/src/agent/do-stream-step.ts Captures tool-result stream parts with providerExecuted: true and returns them in a Map
packages/ai/src/agent/stream-text-iterator.ts Adds ProviderExecutedToolResult interface and passes provider results through the iterator
packages/ai/src/agent/durable-agent.ts Filters tool calls by execution type, executes only client tools locally, and combines results in original order
packages/ai/src/agent/durable-agent.test.ts Adds two new tests validating provider-executed tool handling in isolation and mixed with local tools

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +32
* Provider-executed tool result captured from the stream.
*/
export interface ProviderExecutedToolResult {
toolCallId: string;
toolName: string;
result: unknown;
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc comment for the ProviderExecutedToolResult interface would benefit from more detailed documentation explaining when and how this interface is used, particularly clarifying the relationship with AI SDK v6's provider-executed tools feature and providing examples of which providers support this feature.

Suggested change
* Provider-executed tool result captured from the stream.
*/
export interface ProviderExecutedToolResult {
toolCallId: string;
toolName: string;
result: unknown;
* Result of a provider-executed tool call captured from the model stream.
*
* In AI SDK v6 some providers can execute certain tools (sometimes called
* "built‑in" or "provider‑hosted" tools) on their own infrastructure instead
* of requiring your application to run the tool implementation. When a model
* uses such a tool during a streaming call, the provider may stream back the
* tool's result as part of the model response.
*
* The streaming agent layer detects these provider‑executed tool results and
* exposes them via the {@link StreamTextIteratorYieldValue.providerExecutedToolResults}
* map. Each entry is keyed by the tool call ID so you can correlate it with the
* corresponding {@link LanguageModelV2ToolCall}.
*
* Not all models or providers support provider‑executed tools. Support depends
* on the underlying provider's capabilities (for example, providers that expose
* server‑side web search or code‑execution tools). Refer to the AI SDK and
* individual provider documentation for an up‑to‑date list of supported
* providers and tools.
*
* When {@link isError} is true, {@link result} contains provider‑specific error
* information for the tool call instead of a successful tool payload.
*/
export interface ProviderExecutedToolResult {
/**
* Identifier of the tool call, matching the `id` of the
* {@link LanguageModelV2ToolCall} emitted by the model.
*/
toolCallId: string;
/**
* Name of the tool as defined by the provider (for example, the tool
* name used in the model's tool schema).
*/
toolName: string;
/**
* The value returned by the provider‑executed tool. The shape of this
* object is provider‑ and tool‑specific and is passed through as‑is.
*/
result: unknown;
/**
* Indicates that the provider reported an error when executing the tool.
* When set, {@link result} typically contains error details instead of a
* successful payload.
*/

Copilot uses AI. Check for mistakes.
Comment on lines +829 to +845
const toolResults = toolCalls.map((tc) => {
const clientResult = clientToolResults.find(
(r) => r.toolCallId === tc.toolCallId
);
if (clientResult) return clientResult;
const providerResult = providerToolResults.find(
(r) => r.toolCallId === tc.toolCallId
);
if (providerResult) return providerResult;
// This should never happen, but return empty result as fallback
return {
type: 'tool-result' as const,
toolCallId: tc.toolCallId,
toolName: tc.toolName,
output: { type: 'text' as const, value: '' },
};
});
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for combining tool results has O(n²) complexity. For each tool call in toolCalls, it performs a linear search through both clientToolResults and providerToolResults arrays using find(). This could be inefficient when there are many tool calls.

Consider creating Maps indexed by toolCallId for O(1) lookups instead of using find() on arrays.

Copilot uses AI. Check for mistakes.
Comment on lines +815 to +826
// If no result from stream, return an empty result
// This can happen if the provider didn't send a tool-result stream part
return {
type: 'tool-result' as const,
toolCallId: toolCall.toolCallId,
toolName: toolCall.toolName,
output: {
type: 'text' as const,
value: '',
},
};
});
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a provider-executed tool call doesn't have a corresponding result in the stream, an empty string is returned as the result. This silent failure could make debugging difficult. Consider logging a warning when this fallback is used, as the comment indicates this scenario "can happen if the provider didn't send a tool-result stream part" but it might also indicate an unexpected error condition.

Copilot uses AI. Check for mistakes.
@pranaygp
Copy link
Collaborator Author

pranaygp commented Jan 7, 2026

a solution that seemingly work in AI sdk v5 and v6

image

value:
typeof streamResult.result === 'string'
? streamResult.result
: JSON.stringify(streamResult.result),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: JSON.stringify(streamResult.result),
: JSON.stringify(streamResult.result) ?? '',

JSON.stringify(undefined) returns undefined instead of a string, violating the type contract for the 'value' field

View Details
📝 Patch Details
diff --git a/packages/ai/src/agent/durable-agent.ts b/packages/ai/src/agent/durable-agent.ts
index 4795ea9..ba8e4a8 100644
--- a/packages/ai/src/agent/durable-agent.ts
+++ b/packages/ai/src/agent/durable-agent.ts
@@ -808,7 +808,7 @@ export class DurableAgent<TBaseTools extends ToolSet = ToolSet> {
                     value:
                       typeof streamResult.result === 'string'
                         ? streamResult.result
-                        : JSON.stringify(streamResult.result),
+                        : JSON.stringify(streamResult.result) ?? '',
                   },
                 };
               }

Analysis

The issue was in packages/ai/src/agent/durable-agent.ts at line 811. When handling provider-executed tool results, the code did:

value: typeof streamResult.result === 'string'
  ? streamResult.result
  : JSON.stringify(streamResult.result)

The problem: JSON.stringify(undefined) returns undefined (not a string), which violates the type contract since the value field in LanguageModelV2ToolResultPart should be a string.

This was confirmed by testing:

  • JSON.stringify(undefined) returns undefined with type undefined
  • This causes the value field to be undefined instead of a string

The fix applies the null coalescing operator (??) pattern that was already used elsewhere in the codebase (at line 1053 for local tool results):

value: typeof streamResult.result === 'string'
  ? streamResult.result
  : JSON.stringify(streamResult.result) ?? ''

This ensures:

  • If streamResult.result is a string, use it directly
  • If JSON.stringify() returns a string, use it
  • If JSON.stringify() returns undefined (only when input is undefined), use empty string

The fix makes the provider-executed tool result handling consistent with the local tool result handling pattern used at line 1053.

Fix on Vercel

@pranaygp
Copy link
Collaborator Author

pranaygp commented Jan 7, 2026

Oh this is a duplicate of #434

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.

Support for provider-executed tools (AI SDK v6 / LanguageModelV3) DurableAgent: Tool googleSearch does not have an execute function

3 participants