Skip to content

Fix prepareStep system message lost when messages is also returned#1389

Merged
TooTallNate merged 2 commits intomainfrom
fix/prepare-step-system-message-ordering
Mar 16, 2026
Merged

Fix prepareStep system message lost when messages is also returned#1389
TooTallNate merged 2 commits intomainfrom
fix/prepare-step-system-message-ordering

Conversation

@TooTallNate
Copy link
Member

Summary

  • Fix a bug in DurableAgent's prepareStep where returning both system and messages caused the system message to be discarded
  • The system override was applied first (prepended to conversationPrompt), then messages replaced conversationPrompt entirely, losing the system message
  • Swap the ordering: apply messages first, then system, so the system message is prepended to the new prompt
  • This affected any DurableAgent usage where prepareStep returned a dynamic system prompt alongside modified messages (e.g. for context window management or message injection)

@TooTallNate TooTallNate requested a review from a team as a code owner March 14, 2026 17:32
@vercel
Copy link
Contributor

vercel bot commented Mar 14, 2026

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

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
example-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-astro-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-express-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-fastify-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-hono-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-nitro-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-nuxt-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-sveltekit-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workbench-vite-workflow Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workflow-nest Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm
workflow-swc-playground Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 10:15pm

Copilot AI review requested due to automatic review settings March 14, 2026 17:32
@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2026

🦋 Changeset detected

Latest commit: 93cf09e

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

This PR includes changesets to release 1 package
Name Type
@workflow/ai 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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2026

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 560 0 67 627
✅ 💻 Local Development 600 0 84 684
✅ 📦 Local Production 600 0 84 684
✅ 🐘 Local Postgres 600 0 84 684
✅ 🪟 Windows 54 0 3 57
❌ 🌍 Community Worlds 116 55 15 186
✅ 📋 Other 144 0 27 171
Total 2674 55 364 3093

❌ Failed Tests

🌍 Community Worlds (55 failed)

mongodb (3 failed):

  • hookWorkflow is not resumable via public webhook endpoint
  • webhookWorkflow
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously

redis (2 failed):

  • hookWorkflow is not resumable via public webhook endpoint
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously

turso (50 failed):

  • addTenWorkflow
  • addTenWorkflow
  • wellKnownAgentWorkflow (.well-known/agent)
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • importedStepOnlyWorkflow
  • hookWorkflow
  • hookWorkflow is not resumable via public webhook endpoint
  • webhookWorkflow
  • sleepingWorkflow
  • parallelSleepWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • 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
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running
  • 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 (queue-based) - workflow and step endpoints respond to health check messages
  • 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
  • instanceMethodStepWorkflow - instance methods with "use step" directive
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument
  • cancelRun - cancelling a running workflow
  • cancelRun via CLI - cancelling a running workflow
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router
  • hookWithSleepWorkflow - hook payloads delivered correctly with concurrent sleep
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control)

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 50 0 7
✅ example 50 0 7
✅ express 50 0 7
✅ fastify 50 0 7
✅ hono 50 0 7
✅ nextjs-turbopack 55 0 2
✅ nextjs-webpack 55 0 2
✅ nitro 50 0 7
✅ nuxt 50 0 7
✅ sveltekit 50 0 7
✅ vite 50 0 7
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 48 0 9
✅ express-stable 48 0 9
✅ fastify-stable 48 0 9
✅ hono-stable 48 0 9
✅ nextjs-turbopack-canary 54 0 3
✅ nextjs-turbopack-stable 54 0 3
✅ nextjs-webpack-canary 54 0 3
✅ nextjs-webpack-stable 54 0 3
✅ nitro-stable 48 0 9
✅ nuxt-stable 48 0 9
✅ sveltekit-stable 48 0 9
✅ vite-stable 48 0 9
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 48 0 9
✅ express-stable 48 0 9
✅ fastify-stable 48 0 9
✅ hono-stable 48 0 9
✅ nextjs-turbopack-canary 54 0 3
✅ nextjs-turbopack-stable 54 0 3
✅ nextjs-webpack-canary 54 0 3
✅ nextjs-webpack-stable 54 0 3
✅ nitro-stable 48 0 9
✅ nuxt-stable 48 0 9
✅ sveltekit-stable 48 0 9
✅ vite-stable 48 0 9
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 48 0 9
✅ express-stable 48 0 9
✅ fastify-stable 48 0 9
✅ hono-stable 48 0 9
✅ nextjs-turbopack-canary 54 0 3
✅ nextjs-turbopack-stable 54 0 3
✅ nextjs-webpack-canary 54 0 3
✅ nextjs-webpack-stable 54 0 3
✅ nitro-stable 48 0 9
✅ nuxt-stable 48 0 9
✅ sveltekit-stable 48 0 9
✅ vite-stable 48 0 9
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 54 0 3
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 3 0 2
❌ mongodb 51 3 3
✅ redis-dev 3 0 2
❌ redis 52 2 3
✅ turso-dev 3 0 2
❌ turso 4 50 3
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 48 0 9
✅ e2e-local-postgres-nest-stable 48 0 9
✅ e2e-local-prod-nest-stable 48 0 9

📋 View full workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 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 🥇 Nitro 0.041s (-25.1% 🟢) 1.005s (~) 0.965s 10 1.00x
💻 Local Express 0.042s (+1.9%) 1.006s (~) 0.964s 10 1.04x
💻 Local Next.js (Turbopack) 0.042s 1.005s 0.963s 10 1.04x
🌐 Redis Next.js (Turbopack) 0.053s 1.005s 0.953s 10 1.30x
🐘 Postgres Next.js (Turbopack) 0.059s 1.011s 0.953s 10 1.45x
🐘 Postgres Nitro 0.060s (-0.7%) 1.011s (~) 0.951s 10 1.49x
🌐 MongoDB Next.js (Turbopack) 0.079s 1.008s 0.929s 10 1.95x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 0.426s (-10.4% 🟢) 2.201s (-12.4% 🟢) 1.775s 10 1.00x
▲ Vercel Express 0.480s (-19.0% 🟢) 2.057s (-22.9% 🟢) 1.577s 10 1.13x
▲ Vercel Next.js (Turbopack) 0.507s (-15.3% 🟢) 2.192s (-1.5%) 1.685s 10 1.19x

🔍 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.092s 2.006s 0.913s 10 1.00x
💻 Local Express 1.120s (~) 2.006s (~) 0.886s 10 1.03x
🌐 Redis Next.js (Turbopack) 1.125s 2.007s 0.882s 10 1.03x
💻 Local Nitro 1.129s (~) 2.007s (~) 0.878s 10 1.03x
🐘 Postgres Nitro 1.141s (~) 2.012s (~) 0.871s 10 1.04x
🐘 Postgres Next.js (Turbopack) 1.155s 2.012s 0.857s 10 1.06x
🌐 MongoDB Next.js (Turbopack) 1.310s 2.008s 0.698s 10 1.20x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.037s (-4.2%) 3.323s (-19.8% 🟢) 1.286s 10 1.00x
▲ Vercel Express 2.121s (-0.9%) 3.393s (-16.7% 🟢) 1.272s 10 1.04x
▲ Vercel Next.js (Turbopack) 2.349s (+12.6% 🔺) 3.578s (+5.6% 🔺) 1.229s 10 1.15x

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

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 10.581s 11.022s 0.442s 3 1.00x
🌐 Redis Next.js (Turbopack) 10.753s 11.023s 0.270s 3 1.02x
💻 Local Express 10.891s (~) 11.023s (~) 0.131s 3 1.03x
💻 Local Nitro 10.892s (~) 11.023s (~) 0.132s 3 1.03x
🐘 Postgres Next.js (Turbopack) 10.915s 11.038s 0.123s 3 1.03x
🐘 Postgres Nitro 10.958s (~) 11.375s (-2.9%) 0.417s 3 1.04x
🌐 MongoDB Next.js (Turbopack) 12.216s 13.019s 0.803s 3 1.15x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 16.477s (-15.4% 🟢) 17.328s (-17.9% 🟢) 0.851s 2 1.00x
▲ Vercel Next.js (Turbopack) 16.667s (-1.5%) 18.125s (-1.1%) 1.458s 2 1.01x
▲ Vercel Nitro 16.950s (+2.6%) 18.598s (+3.6%) 1.648s 2 1.03x

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

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 26.621s 27.049s 0.428s 3 1.00x
🌐 Redis Next.js (Turbopack) 26.777s 27.052s 0.275s 3 1.01x
🐘 Postgres Next.js (Turbopack) 26.955s 27.065s 0.110s 3 1.01x
🐘 Postgres Nitro 27.199s (~) 28.064s (~) 0.865s 3 1.02x
💻 Local Nitro 27.451s (~) 28.051s (~) 0.600s 3 1.03x
💻 Local Express 27.458s (~) 28.050s (~) 0.592s 3 1.03x
🌐 MongoDB Next.js (Turbopack) 30.380s 31.037s 0.657s 2 1.14x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 43.820s (-5.5% 🟢) 45.150s (-6.8% 🟢) 1.330s 2 1.00x
▲ Vercel Next.js (Turbopack) 43.889s (+0.7%) 45.248s (~) 1.359s 2 1.00x
▲ Vercel Nitro 44.008s (~) 45.019s (-0.9%) 1.011s 2 1.00x

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

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 53.383s 54.099s 0.716s 2 1.00x
🐘 Postgres Next.js (Turbopack) 53.959s 54.097s 0.138s 2 1.01x
🐘 Postgres Nitro 54.176s (~) 54.597s (-0.9%) 0.421s 2 1.01x
💻 Local Next.js (Turbopack) 54.697s 55.105s 0.408s 2 1.02x
💻 Local Nitro 56.405s (-0.6%) 57.101s (~) 0.696s 2 1.06x
💻 Local Express 56.553s (~) 57.102s (~) 0.548s 2 1.06x
🌐 MongoDB Next.js (Turbopack) 60.642s 61.066s 0.425s 2 1.14x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 94.669s (~) 96.588s (~) 1.919s 1 1.00x
▲ Vercel Next.js (Turbopack) 94.803s (-1.6%) 96.243s (-2.0%) 1.440s 1 1.00x
▲ Vercel Express 99.053s (~) 100.244s (~) 1.191s 1 1.05x

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

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.337s 2.006s 0.670s 15 1.00x
🐘 Postgres Nitro 1.417s (+0.9%) 2.010s (~) 0.593s 15 1.06x
🐘 Postgres Next.js (Turbopack) 1.457s 2.011s 0.554s 15 1.09x
💻 Local Next.js (Turbopack) 1.471s 2.005s 0.534s 15 1.10x
💻 Local Nitro 1.500s (-1.4%) 2.006s (~) 0.506s 15 1.12x
💻 Local Express 1.516s (~) 2.006s (~) 0.490s 15 1.13x
🌐 MongoDB Next.js (Turbopack) 2.166s 3.009s 0.843s 10 1.62x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.328s (-9.5% 🟢) 3.653s (-8.6% 🟢) 1.325s 9 1.00x
▲ Vercel Express 2.483s (-6.7% 🟢) 3.675s (-17.0% 🟢) 1.191s 9 1.07x
▲ Vercel Next.js (Turbopack) 2.712s (+15.4% 🔺) 3.854s (+1.8%) 1.141s 8 1.17x

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

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 2.542s 2.825s 0.282s 11 1.00x
🌐 Redis Next.js (Turbopack) 2.573s 3.008s 0.435s 10 1.01x
🐘 Postgres Nitro 2.574s (-0.9%) 3.114s (+3.3%) 0.540s 10 1.01x
🐘 Postgres Next.js (Turbopack) 2.596s 3.012s 0.416s 10 1.02x
💻 Local Express 2.836s (-2.1%) 3.108s (-3.1%) 0.272s 10 1.12x
💻 Local Nitro 2.873s (-2.4%) 3.108s (-7.0% 🟢) 0.235s 10 1.13x
🌐 MongoDB Next.js (Turbopack) 4.696s 5.178s 0.482s 6 1.85x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.713s (-7.4% 🟢) 3.971s (-21.1% 🟢) 1.258s 8 1.00x
▲ Vercel Next.js (Turbopack) 2.793s (+7.9% 🔺) 4.382s (-1.8%) 1.589s 7 1.03x
▲ Vercel Express 3.048s (+3.2%) 4.351s (-3.8%) 1.303s 7 1.12x

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

Promise.all with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 4.158s 5.011s 0.853s 6 1.00x
🐘 Postgres Nitro 4.219s (+6.1% 🔺) 4.730s (+6.4% 🔺) 0.511s 7 1.01x
🐘 Postgres Next.js (Turbopack) 4.284s 5.021s 0.737s 6 1.03x
💻 Local Next.js (Turbopack) 6.452s 7.015s 0.563s 5 1.55x
💻 Local Express 7.927s (-1.5%) 8.522s (~) 0.595s 4 1.91x
💻 Local Nitro 8.008s (-3.6%) 8.518s (-5.6% 🟢) 0.510s 4 1.93x
🌐 MongoDB Next.js (Turbopack) 9.891s 10.349s 0.458s 3 2.38x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 3.499s (+17.8% 🔺) 5.006s (-4.2%) 1.507s 6 1.00x
▲ Vercel Next.js (Turbopack) 3.584s (-11.5% 🟢) 5.051s (-10.6% 🟢) 1.466s 7 1.02x
▲ Vercel Nitro 4.678s (+33.4% 🔺) 6.012s (+20.9% 🔺) 1.334s 5 1.34x

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

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.296s 2.006s 0.711s 15 1.00x
🐘 Postgres Nitro 1.378s (-1.0%) 2.011s (~) 0.633s 15 1.06x
🐘 Postgres Next.js (Turbopack) 1.430s 2.011s 0.581s 15 1.10x
💻 Local Express 1.484s (-2.0%) 2.006s (~) 0.522s 15 1.14x
💻 Local Next.js (Turbopack) 1.494s 2.005s 0.511s 15 1.15x
💻 Local Nitro 1.502s (-5.0% 🟢) 2.005s (~) 0.503s 15 1.16x
🌐 MongoDB Next.js (Turbopack) 2.209s 3.008s 0.799s 10 1.70x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.110s (-7.5% 🟢) 3.513s (-8.7% 🟢) 1.402s 9 1.00x
▲ Vercel Nitro 2.659s (+7.2% 🔺) 3.904s (-13.8% 🟢) 1.245s 9 1.26x
▲ Vercel Express 2.725s (+17.1% 🔺) 3.988s (-7.0% 🟢) 1.263s 8 1.29x

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

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 2.501s (-0.7%) 3.011s (~) 0.510s 10 1.00x
🐘 Postgres Next.js (Turbopack) 2.596s 3.013s 0.417s 10 1.04x
🌐 Redis Next.js (Turbopack) 2.618s 3.008s 0.390s 10 1.05x
💻 Local Next.js (Turbopack) 2.639s 3.008s 0.368s 10 1.06x
💻 Local Express 2.904s (-4.9%) 3.009s (-20.0% 🟢) 0.105s 10 1.16x
💻 Local Nitro 2.926s (-8.0% 🟢) 3.343s (-16.7% 🟢) 0.417s 9 1.17x
🌐 MongoDB Next.js (Turbopack) 4.705s 5.177s 0.472s 6 1.88x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.612s (+6.5% 🔺) 4.010s (+2.5%) 1.398s 9 1.00x
▲ Vercel Nitro 2.615s (+5.5% 🔺) 3.792s (-18.0% 🟢) 1.178s 8 1.00x
▲ Vercel Express 2.652s (+1.3%) 3.661s (-21.1% 🟢) 1.009s 9 1.02x

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

Promise.race with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 3.969s (+0.9%) 4.589s (+3.2%) 0.620s 7 1.00x
🌐 Redis Next.js (Turbopack) 4.152s 5.011s 0.860s 6 1.05x
🐘 Postgres Next.js (Turbopack) 4.370s 5.016s 0.646s 6 1.10x
💻 Local Next.js (Turbopack) 6.371s 6.816s 0.445s 5 1.61x
💻 Local Nitro 8.241s (-6.8% 🟢) 9.020s (-2.7%) 0.779s 4 2.08x
💻 Local Express 8.431s (-3.4%) 9.020s (-2.7%) 0.589s 4 2.12x
🌐 MongoDB Next.js (Turbopack) 9.959s 10.684s 0.724s 3 2.51x
🐘 Postgres Express ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.934s (+8.9% 🔺) 4.148s (-12.1% 🟢) 1.214s 8 1.00x
▲ Vercel Nitro 3.072s (+7.5% 🔺) 4.315s (-9.7% 🟢) 1.243s 7 1.05x
▲ Vercel Next.js (Turbopack) 3.314s (-46.2% 🟢) 4.719s (-39.7% 🟢) 1.405s 7 1.13x

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

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.129s 1.002s 0.010s 1.015s 0.887s 10 1.00x
🌐 Redis Next.js (Turbopack) 0.173s 1.000s 0.002s 1.008s 0.834s 10 1.35x
💻 Local Express 0.192s (-2.3%) 1.003s (~) 0.012s (+2.7%) 1.017s (~) 0.826s 10 1.49x
💻 Local Nitro 0.193s (-5.9% 🟢) 1.003s (~) 0.011s (-9.8% 🟢) 1.017s (~) 0.824s 10 1.50x
🐘 Postgres Next.js (Turbopack) 0.203s 1.002s 0.002s 1.012s 0.810s 10 1.58x
🐘 Postgres Nitro 0.216s (-4.6%) 0.993s (~) 0.002s (-21.1% 🟢) 1.011s (~) 0.795s 10 1.68x
🌐 MongoDB Next.js (Turbopack) 0.523s 0.928s 0.001s 1.009s 0.485s 10 4.07x
🐘 Postgres Express ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 1.483s (-5.0% 🟢) 2.197s (-21.4% 🟢) 0.005s (+31.7% 🔺) 2.741s (-18.4% 🟢) 1.258s 10 1.00x
▲ Vercel Nitro 1.590s (-1.8%) 2.652s (-3.0%) 0.006s (+5.6% 🔺) 3.205s (-1.9%) 1.615s 10 1.07x
▲ Vercel Express 1.594s (-13.2% 🟢) 2.753s (-4.0%) 0.006s (+20.4% 🔺) 3.285s (-5.5% 🟢) 1.691s 10 1.07x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

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

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 💻 Local 9/12
Next.js (Turbopack) 💻 Local 6/12
Nitro 🐘 Postgres 7/12
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
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: failure
  • Vercel: success

Check the workflow run for details.

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

Fixes a DurableAgent/streamTextIterator bug where a prepareStep callback returning both messages and system would inadvertently drop the system message due to override ordering.

Changes:

  • Apply prepareStep.messages override before applying prepareStep.system, ensuring the system message is preserved.
  • Add a changeset to publish the fix as a patch for @workflow/ai.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/ai/src/agent/stream-text-iterator.ts Reorders prepareStep override application so system is applied after messages.
.changeset/fix-prepare-step-system-ordering.md Adds a patch changeset entry documenting the bug fix.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 151 to 174
@@ -167,9 +172,6 @@ export async function* streamTextIterator({
});
}
}
Apply messages override before system override so that the system
message is prepended to the new prompt instead of being discarded.
Previously, system was applied first then messages replaced the
entire conversation prompt, losing the system message.

Add tests for prepareStep system/messages ordering:
- system only: prepended to prompt
- system + messages: system prepended to replaced messages
- system + messages with existing system: replaces existing
- system updates across multi-step tool call rounds
'@workflow/ai': patch
---

Fix `prepareStep` system message being discarded when `messages` is also returned
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add an e2e test for this to prevent regressions @TooTallNate? since we now have the DurableAgent e2e test infra as of this week :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

also when relevant/possible, we should update the DurableAgent chat app to use the feature - for example when adding/fixing provider tools and client side tools, I would've been good to add that feature to the app as an easy way to try it and see if it actually works and the DX for it (the app didn't exist at the time and the friction to do a tarball and test with flight booking app is a bit annoying)

maybe this time we should have something in the DurableAgent test app that uses prepareStep?

@TooTallNate TooTallNate merged commit 4a298b5 into main Mar 16, 2026
164 of 168 checks passed
@TooTallNate TooTallNate deleted the fix/prepare-step-system-message-ordering branch March 16, 2026 22:37
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.

4 participants