Skip to content

feat(ai): experimental callbacks for streamText#12708

Merged
aayush-kapoor merged 17 commits intomainfrom
aayush/callbacks-stream-text
Feb 20, 2026
Merged

feat(ai): experimental callbacks for streamText#12708
aayush-kapoor merged 17 commits intomainfrom
aayush/callbacks-stream-text

Conversation

@aayush-kapoor
Copy link
Copy Markdown
Collaborator

@aayush-kapoor aayush-kapoor commented Feb 19, 2026

Background

as a follow up to #12654, we will introduce the same callbacks for streamText function

Summary

  • added callback experimental_onStart that exposes the data/events that happen at the very beginning
  • added callback experimental_onStepStart
  • added callback experimental_onToolCallStart
  • added callback experimental_onToolCallFinish

Manual Verification

Checklist

  • 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)

Future Work

  • add similar callbacks for the agent loop

@tigent tigent bot added ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. feature New feature or request labels Feb 19, 2026
export type StreamTextOnStartCallback<
TOOLS extends ToolSet = ToolSet,
OUTPUT extends Output = Output,
> = (event: {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can the events be extracted (from generate and stream text into XXXEvent types/interfaces) or are there differences?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

extracted - changed for generateText as well

@aayush-kapoor aayush-kapoor merged commit 30c9de6 into main Feb 20, 2026
18 checks passed
@aayush-kapoor aayush-kapoor deleted the aayush/callbacks-stream-text branch February 20, 2026 20:02
aayush-kapoor added a commit that referenced this pull request Feb 20, 2026
## Background

as a follow up to #12654, we will
introduce the same callbacks for the `ToolLoopAgent`

## Summary

- added callback `experimental_onStart` that exposes the data/events
that happen at the very beginning
- added callback `experimental_onStepStart`
- added callback `experimental_onToolCallStart`
- added callback `experimental_onToolCallFinish`

## Manual Verification

## Future Work

- callbacks aren't currently passed through for streaming - will need to
merge #12708 first

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [x] 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)
@aayush-kapoor aayush-kapoor linked an issue Apr 9, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add experimental callbacks to all core functions

2 participants