feat(ai): add an event emitter to core functions#12749
Merged
aayush-kapoor merged 18 commits intomainfrom Feb 25, 2026
Merged
Conversation
aayush-kapoor
commented
Feb 20, 2026
lgrammel
reviewed
Feb 23, 2026
lgrammel
reviewed
Feb 23, 2026
lgrammel
reviewed
Feb 23, 2026
4 tasks
lgrammel
reviewed
Feb 24, 2026
lgrammel
reviewed
Feb 24, 2026
lgrammel
reviewed
Feb 24, 2026
lgrammel
reviewed
Feb 24, 2026
lgrammel
reviewed
Feb 24, 2026
lgrammel
reviewed
Feb 24, 2026
lgrammel
approved these changes
Feb 24, 2026
lgrammel
reviewed
Feb 25, 2026
lgrammel
reviewed
Feb 25, 2026
lgrammel
reviewed
Feb 25, 2026
Comment on lines
+9
to
+12
| export async function notify<EVENT>(options: { | ||
| event: EVENT; | ||
| callbacks?: Listener<EVENT> | Array<Listener<EVENT>>; | ||
| }): Promise<void> { |
lgrammel
approved these changes
Feb 25, 2026
lgrammel
reviewed
Feb 25, 2026
Comment on lines
1279
to
+1308
| @@ -1298,10 +1303,9 @@ class DefaultStreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> | |||
| include, | |||
| ...callbackTelemetryProps, | |||
| experimental_context, | |||
| }); | |||
| } catch (_ignored) { | |||
| // Errors in callbacks should not break the generation flow. | |||
| } | |||
| }, | |||
| callbacks: onStart, | |||
| }); | |||
Collaborator
There was a problem hiding this comment.
looks great and allows us to extend as well in the future
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
as a part of the ongoing change to refactor telemetry, the idea is to create an event emitter (that basically emits all the information that is present at that step of the flow) so that listeners (such as OTel) can tap into the information and create spans accordingly
Summary
Manual Verification
examples/ai-functions/src/events/listen-to-events.tsChecklist
pnpm changesetin the project root)Future Work