Skip to content

feat(ai): add onStepEnd support to toUIMessageStream - #21150

Open
mohankumarelec wants to merge 2 commits into
vercel:mainfrom
mohankumarelec:feat/to-ui-message-stream-on-step-end
Open

mohankumarelec wants to merge 2 commits into
vercel:mainfrom
mohankumarelec:feat/to-ui-message-stream-on-step-end

Conversation

@mohankumarelec

@mohankumarelec mohankumarelec commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Background

toUIMessageStream accepted onEnd but did not expose step-level callbacks.

Summary

  • add onStepEnd and deprecated onStepFinish to UIMessageStreamOptions
  • pass step callbacks through toUIMessageStream into handleUIMessageStreamFinish
  • add tests covering onStepEnd and precedence over onStepFinish

No docs update needed; this change adds callback passthrough parity.

End-to-End Verification

  • pnpm exec vitest run src/ui-message-stream/to-ui-message-stream.test.ts --config vitest.node.config.js --typecheck.enabled false

Checklist

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

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Suggestion:

StreamTextResult UI-stream methods silently drop the onStepEnd/onStepFinish callbacks, so they are never invoked at runtime.

Fix on Vercel

@mohankumarelec
mohankumarelec force-pushed the feat/to-ui-message-stream-on-step-end branch 2 times, most recently from dcbc8fd to 5e7cd03 Compare September 18, 2026 16:30
@mohankumarelec
mohankumarelec force-pushed the feat/to-ui-message-stream-on-step-end branch from 5e7cd03 to 9034de0 Compare September 18, 2026 16:32
@mohankumarelec

Copy link
Copy Markdown
Contributor Author

Additional Suggestion:

StreamTextResult UI-stream methods silently drop the onStepEnd/onStepFinish callbacks, so they are never invoked at runtime.

Fix on Vercel

Fixed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant