feat(core): Migrate Vercel AI event processor to span streaming#20608
Merged
nicohrubec merged 12 commits intodevelopfrom May 6, 2026
Merged
feat(core): Migrate Vercel AI event processor to span streaming#20608nicohrubec merged 12 commits intodevelopfrom
nicohrubec merged 12 commits intodevelopfrom
Conversation
…sor migration Closes #20377 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
size-limit report 📦
|
… description side-channel Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ions The error scenario needs a try/catch so the process stays alive for flush. The invoke_agent span doesn't have token attributes when the tool errors, so remove those from the error test expectations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… test In Vercel AI v6, the invoke_agent span does not get error status when a tool errors (matching the non-streaming v6 test behavior). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
chargome
reviewed
May 6, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 44cc789. Configure here.
chargome
approved these changes
May 6, 2026
Member
chargome
left a comment
There was a problem hiding this comment.
Thanks for updating! LGTM now, I just hope we didn't overlook any edge cases where the map might leak 📿
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.

Migrates the Vercel AI event processor so it also works in the span streaming path via the
processSpanhook. The event processor currently serves three purposes:Attribute renaming. The Vercel AI SDK emits attributes under
ai.*names that need to be renamed to OpenTelemetry semantic conventions (gen_ai.*) and thevercel.ai.*namespace. This logic is straightforward to port. It's extracted into a sharedprocessVercelAiSpanAttributeshelper that is now called from both the legacy event processor path (for transactions) and the newprocessSpanhook (for streamed spans).Token accumulation on parent spans. The event processor aggregates token usage from child spans onto their parent
invoke_agentspans. This is a cross-span operation that fundamentally doesn't work in the streaming model where spans are processed individually. The span streaming implementation guide explicitly lists this as a case that cannot be replaced. Since the plan is for parent-level token accumulation to go away regardless, we simply drop it for the streaming path.Tool descriptions on execute_tool spans. The event processor iterates over all spans in a transaction to find
gen_ai.request.available_toolsondoGeneratespans and applies the matching description to siblingexecute_toolspans. This cross-span iteration doesn't work when spans are processed individually. Instead, we parse and store tool descriptions in a map atspanStarttime of thedoGeneratespan. Sinceexecute_toolspans are siblings ofdoGenerate(both children ofinvoke_agent), we key the map by the parent span ID soexecute_toolspans can look up descriptions by their ownparent_span_id. This assumes a flat sibling hierarchy, which holds for our test scenarios. If we encounter more complex cases down the road, I think it's fine to address in a follow-up.Closes #20377