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)

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: 0a7c30c

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 27, 2026 9:38pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jan 27, 2026 9:38pm
example-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-astro-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-express-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-fastify-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-hono-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-nitro-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-nuxt-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workbench-vite-workflow Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workflow-docs Ready Ready Preview, Comment Jan 27, 2026 9:38pm
workflow-nest Ready Ready Preview, Comment Jan 27, 2026 9:38pm

@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 457 0 38 495
✅ 💻 Local Development 418 0 32 450
✅ 📦 Local Production 418 0 32 450
✅ 🐘 Local Postgres 418 0 32 450
✅ 🪟 Windows 45 0 0 45
❌ 🌍 Community Worlds 31 161 0 192
✅ 📋 Other 123 0 12 135
Total 1910 161 146 2217

❌ Failed Tests

🌍 Community Worlds (161 failed)

mongodb (40 failed):

  • addTenWorkflow
  • addTenWorkflow
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • readableStreamWorkflow
  • hookWorkflow
  • webhookWorkflow
  • sleepingWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • outputStreamWorkflow
  • outputStreamInsideStepWorkflow - getWritable() called inside step functions
  • fetchWorkflow
  • promiseRaceStressTestWorkflow
  • 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 retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • closureVariableWorkflow - nested step functions with closure variables
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly
  • Calculator.calculate - static workflow method using static step methods from another class
  • AllInOneService.processNumber - static workflow method using sibling static step methods
  • ChainableService.processWithThis - static step methods using this to reference the class
  • thisSerializationWorkflow - step function invoked with .call() and .apply()
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router

redis (40 failed):

  • addTenWorkflow
  • addTenWorkflow
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • readableStreamWorkflow
  • hookWorkflow
  • webhookWorkflow
  • sleepingWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • outputStreamWorkflow
  • outputStreamInsideStepWorkflow - getWritable() called inside step functions
  • fetchWorkflow
  • promiseRaceStressTestWorkflow
  • 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 retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • closureVariableWorkflow - nested step functions with closure variables
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly
  • Calculator.calculate - static workflow method using static step methods from another class
  • AllInOneService.processNumber - static workflow method using sibling static step methods
  • ChainableService.processWithThis - static step methods using this to reference the class
  • thisSerializationWorkflow - step function invoked with .call() and .apply()
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router

starter (41 failed):

  • addTenWorkflow
  • addTenWorkflow
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • readableStreamWorkflow
  • hookWorkflow
  • webhookWorkflow
  • sleepingWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • outputStreamWorkflow
  • outputStreamInsideStepWorkflow - getWritable() called inside step functions
  • fetchWorkflow
  • promiseRaceStressTestWorkflow
  • 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 retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • closureVariableWorkflow - nested step functions with closure variables
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • health check (CLI) - workflow health command reports healthy endpoints
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly
  • Calculator.calculate - static workflow method using static step methods from another class
  • AllInOneService.processNumber - static workflow method using sibling static step methods
  • ChainableService.processWithThis - static step methods using this to reference the class
  • thisSerializationWorkflow - step function invoked with .call() and .apply()
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router

turso (40 failed):

  • addTenWorkflow
  • addTenWorkflow
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • readableStreamWorkflow
  • hookWorkflow
  • webhookWorkflow
  • sleepingWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • outputStreamWorkflow
  • outputStreamInsideStepWorkflow - getWritable() called inside step functions
  • fetchWorkflow
  • promiseRaceStressTestWorkflow
  • 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 retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • closureVariableWorkflow - nested step functions with closure variables
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly
  • Calculator.calculate - static workflow method using static step methods from another class
  • AllInOneService.processNumber - static workflow method using sibling static step methods
  • ChainableService.processWithThis - static step methods using this to reference the class
  • thisSerializationWorkflow - step function invoked with .call() and .apply()
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 41 0 4
✅ example 41 0 4
✅ express 41 0 4
✅ fastify 41 0 4
✅ hono 41 0 4
✅ nextjs-turbopack 44 0 1
✅ nextjs-webpack 44 0 1
✅ nitro 41 0 4
✅ nuxt 41 0 4
✅ sveltekit 41 0 4
✅ vite 41 0 4
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 41 0 4
✅ express-stable 41 0 4
✅ fastify-stable 41 0 4
✅ hono-stable 41 0 4
✅ nextjs-turbopack-stable 45 0 0
✅ nextjs-webpack-stable 45 0 0
✅ nitro-stable 41 0 4
✅ nuxt-stable 41 0 4
✅ sveltekit-stable 41 0 4
✅ vite-stable 41 0 4
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 41 0 4
✅ express-stable 41 0 4
✅ fastify-stable 41 0 4
✅ hono-stable 41 0 4
✅ nextjs-turbopack-stable 45 0 0
✅ nextjs-webpack-stable 45 0 0
✅ nitro-stable 41 0 4
✅ nuxt-stable 41 0 4
✅ sveltekit-stable 41 0 4
✅ vite-stable 41 0 4
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 41 0 4
✅ express-stable 41 0 4
✅ fastify-stable 41 0 4
✅ hono-stable 41 0 4
✅ nextjs-turbopack-stable 45 0 0
✅ nextjs-webpack-stable 45 0 0
✅ nitro-stable 41 0 4
✅ nuxt-stable 41 0 4
✅ sveltekit-stable 41 0 4
✅ vite-stable 41 0 4
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 45 0 0
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 3 0 0
❌ mongodb 5 40 0
✅ redis-dev 3 0 0
❌ redis 5 40 0
✅ starter-dev 3 0 0
❌ starter 4 41 0
✅ turso-dev 3 0 0
❌ turso 5 40 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 41 0 4
✅ e2e-local-postgres-nest-stable 41 0 4
✅ e2e-local-prod-nest-stable 41 0 4

📋 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
💻 Local 🥇 Next.js (Turbopack) 0.042s (-2.6%) 1.017s (~) 0.976s 10 1.00x
💻 Local Express 0.043s (~) 1.008s (~) 0.965s 10 1.04x
💻 Local Nitro 0.043s (-14.9% 🟢) 1.007s (~) 0.963s 10 1.04x
🐘 Postgres Nitro 0.162s (-34.7% 🟢) 1.026s (+1.3%) 0.865s 10 3.88x
🐘 Postgres Express 0.275s (~) 1.015s (-0.6%) 0.740s 10 6.61x
🐘 Postgres Next.js (Turbopack) 0.368s (+17.1% 🔺) 1.020s (~) 0.652s 10 8.84x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 0.664s (-16.6% 🟢) 1.491s (-17.1% 🟢) 0.827s 10 1.00x
▲ Vercel Express 0.680s (-11.2% 🟢) 1.631s (-12.8% 🟢) 0.951s 10 1.02x
▲ Vercel Nitro 0.680s (-10.2% 🟢) 1.523s (-10.9% 🟢) 0.843s 10 1.02x

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

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 1.092s (~) 2.012s (~) 0.920s 10 1.00x
💻 Local Express 1.118s (~) 2.008s (~) 0.890s 10 1.02x
💻 Local Nitro 1.118s (~) 2.007s (~) 0.888s 10 1.02x
🐘 Postgres Next.js (Turbopack) 1.637s (-8.1% 🟢) 2.015s (~) 0.378s 10 1.50x
🐘 Postgres Express 2.120s (-6.5% 🟢) 3.014s (~) 0.893s 10 1.94x
🐘 Postgres Nitro 2.468s (+17.1% 🔺) 3.014s (~) 0.547s 10 2.26x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.917s (-4.8%) 3.630s (-6.9% 🟢) 0.712s 10 1.00x
▲ Vercel Nitro 2.945s (+2.3%) 3.674s (-2.2%) 0.729s 10 1.01x
▲ Vercel Express 3.260s (+9.3% 🔺) 4.180s (+10.3% 🔺) 0.920s 10 1.12x

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

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 10.715s (~) 11.018s (~) 0.303s 5 1.00x
💻 Local Express 10.845s (~) 11.015s (~) 0.170s 5 1.01x
💻 Local Nitro 10.846s (~) 11.015s (~) 0.169s 5 1.01x
🐘 Postgres Next.js (Turbopack) 14.082s (-7.5% 🟢) 14.627s (-7.7% 🟢) 0.545s 5 1.31x
🐘 Postgres Nitro 15.844s (-22.6% 🟢) 16.432s (-21.8% 🟢) 0.588s 5 1.48x
🐘 Postgres Express 20.447s (~) 21.038s (~) 0.592s 5 1.91x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 22.681s (-0.8%) 23.362s (-0.7%) 0.681s 5 1.00x
▲ Vercel Next.js (Turbopack) 22.884s (~) 23.463s (-1.6%) 0.579s 5 1.01x
▲ Vercel Nitro 23.761s (+4.2%) 24.289s (+3.5%) 0.528s 5 1.05x

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

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 1.390s (~) 2.013s (~) 0.623s 15 1.00x
💻 Local Nitro 1.401s (-1.0%) 2.007s (~) 0.606s 15 1.01x
💻 Local Express 1.414s (+2.4%) 2.006s (~) 0.592s 15 1.02x
🐘 Postgres Nitro 1.949s (-15.2% 🟢) 2.742s (-9.0% 🟢) 0.792s 11 1.40x
🐘 Postgres Express 2.148s (-10.7% 🟢) 3.020s (~) 0.871s 10 1.55x
🐘 Postgres Next.js (Turbopack) 2.187s (+31.6% 🔺) 2.680s (+28.7% 🔺) 0.493s 12 1.57x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.859s (-12.1% 🟢) 3.663s (-8.8% 🟢) 0.805s 9 1.00x
▲ Vercel Nitro 3.150s (+5.4% 🔺) 4.036s (+4.1%) 0.887s 8 1.10x
▲ Vercel Express 3.543s (+18.1% 🔺) 4.370s (+11.9% 🔺) 0.827s 7 1.24x

🔍 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 🥇 Express 2.462s (+1.8%) 3.041s (-1.7%) 0.580s 10 1.00x
💻 Local Next.js (Turbopack) 2.480s (~) 3.125s (+2.5%) 0.645s 10 1.01x
💻 Local Nitro 2.592s (+4.9%) 3.011s (-1.3%) 0.420s 10 1.05x
🐘 Postgres Express 8.402s (-7.1% 🟢) 8.816s (-5.4% 🟢) 0.415s 4 3.41x
🐘 Postgres Nitro 8.735s (-6.9% 🟢) 9.536s (-5.4% 🟢) 0.801s 4 3.55x
🐘 Postgres Next.js (Turbopack) 13.555s (+10.4% 🔺) 14.042s (+9.8% 🔺) 0.487s 3 5.51x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 3.418s (+3.7%) 4.184s (+3.6%) 0.765s 8 1.00x
▲ Vercel Nitro 3.497s (+5.3% 🔺) 4.068s (-1.1%) 0.571s 8 1.02x
▲ Vercel Next.js (Turbopack) 3.695s (-8.0% 🟢) 4.556s (-6.4% 🟢) 0.861s 7 1.08x

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

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 1.416s (-0.8%) 2.011s (~) 0.595s 15 1.00x
💻 Local Express 1.421s (~) 2.007s (~) 0.586s 15 1.00x
💻 Local Nitro 1.442s (+1.9%) 2.006s (~) 0.564s 15 1.02x
🐘 Postgres Nitro 1.998s (-9.5% 🟢) 2.227s (-11.3% 🟢) 0.229s 14 1.41x
🐘 Postgres Express 2.083s (+2.3%) 2.605s (-3.0%) 0.522s 12 1.47x
🐘 Postgres Next.js (Turbopack) 2.316s (-2.7%) 2.746s (-3.2%) 0.430s 11 1.64x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.842s (-5.7% 🟢) 3.683s (-5.4% 🟢) 0.841s 9 1.00x
▲ Vercel Next.js (Turbopack) 2.915s (+5.2% 🔺) 3.643s (-4.4%) 0.728s 9 1.03x
▲ Vercel Express 3.005s (+12.2% 🔺) 3.921s (+10.3% 🔺) 0.916s 8 1.06x

🔍 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.494s (-8.6% 🟢) 3.037s (~) 0.543s 10 1.00x
💻 Local Express 2.518s (+1.1%) 3.013s (~) 0.495s 10 1.01x
💻 Local Nitro 2.720s (+5.0% 🔺) 3.011s (-0.6%) 0.292s 10 1.09x
🐘 Postgres Nitro 10.927s (+2.3%) 11.375s (~) 0.448s 3 4.38x
🐘 Postgres Express 11.988s (+2.0%) 12.398s (+2.9%) 0.410s 3 4.81x
🐘 Postgres Next.js (Turbopack) 13.411s (-5.1% 🟢) 14.034s (-4.7%) 0.622s 3 5.38x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 3.101s (+1.0%) 3.809s (-2.8%) 0.708s 8 1.00x
▲ Vercel Nitro 3.137s (+1.6%) 3.883s (~) 0.746s 8 1.01x
▲ Vercel Express 3.471s (+2.7%) 4.139s (+1.3%) 0.667s 8 1.12x

🔍 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
💻 Local 🥇 Next.js (Turbopack) 0.146s (-1.3%) 1.003s (~) 0.017s (+1.8%) 1.028s (~) 0.882s 10 1.00x
💻 Local Nitro 0.184s (+0.9%) 0.993s (~) 0.015s (+8.8% 🔺) 1.022s (~) 0.838s 10 1.27x
💻 Local Express 0.185s (+2.5%) 0.993s (~) 0.015s (+10.1% 🔺) 1.023s (~) 0.838s 10 1.27x
🐘 Postgres Next.js (Turbopack) 0.716s (-47.6% 🟢) 0.725s (-56.9% 🟢) 0.000s (~) 1.015s (-49.7% 🟢) 0.299s 10 4.91x
🐘 Postgres Nitro 1.214s (-48.2% 🟢) 1.906s (-29.3% 🟢) 0.000s (NaN%) 2.013s (-33.2% 🟢) 0.799s 10 8.33x
🐘 Postgres Express 2.234s (+2.7%) 2.803s (-2.2%) 0.000s (NaN%) 3.016s (~) 0.782s 10 15.33x

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.975s (-2.7%) 3.254s (+1.2%) 0.625s (-14.0% 🟢) 4.496s (+2.4%) 1.521s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.999s (-0.8%) 3.217s (-0.8%) 0.831s (+78.3% 🔺) 4.517s (+5.6% 🔺) 1.518s 10 1.01x
▲ Vercel Nitro 3.020s (~) 3.212s (-1.1%) 0.566s (-15.0% 🟢) 4.274s (-4.1%) 1.255s 10 1.02x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

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

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 💻 Local 8/8
Next.js (Turbopack) 💻 Local 8/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 +874
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 855
// 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

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
Use 'json' type for object results and 'text' type for string results,
matching the AI SDK spec (LanguageModelV2ToolResultOutput).

Before: Always used 'text' with JSON.stringify(result)
After:  Use 'json' with raw value for objects, 'text' for strings

This aligns with AI SDK types and fixes compatibility with
writeToolOutputToUI which no longer needs to JSON.parse.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@pranaygp pranaygp merged commit 8e87b24 into main Jan 27, 2026
90 checks passed
@pranaygp pranaygp deleted the pranaygp/fix-628 branch January 27, 2026 21:40
pranaygp added a commit that referenced this pull request Jan 28, 2026
…s-and-commands

* origin/main:
  fix(@workflow/ai): support provider-executed tools (AI SDK v6) (#734)
  Publish "workflow" and "@workflow/core" package versions in sync (#870)
  Add SDK version to workflow run executionContext for observability (#868)
  Allow recreateRun to accept an optional deploymentId parameter (#869)
  Add support for top-level `using` declarations inside of step / workflow functions (#866)
  docs: URL in docs was missing the docs/ prefix, 404 errors (#852)
  Add "classes" object to `manifest.json` file (#864)
  Fix Nest workbench app build (#865)
  Ignore Astro on local dev tests for source map e2e tests (#863)
  Enable custom class serialization transformations for "client" mode (#860)
  Submit request bodies with CBOR encoding (#844)
  [world-vercel] Update queue to use VQS v3 API (#799)
  NestJS framework support (#840)
  Fix resolve hook theming and token fetching. (#856)
  docs: rename Control Flow Patterns to Common Patterns and add new content (#846)
  docs: revamp World documentation pages (#763)
  Remove unused `getWritable` stub function (#855)

# Conflicts:
#	packages/core/package.json
#	pnpm-lock.yaml
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